Saved the app as a module and trying to run an activity (or fragment) in another app . But almost all fields return null . The essence of the problem is to make a module from the current app so that you can use this activity or a fragment in another application. Any ideas? Thank.

Original activity:

  protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnFlip = (ImageButton) findViewById(R.id.btnFlip); btnQrCode = (ImageButton) findViewById(R.id.btnQr); 

as I launch it in the new app:

  protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent i = new Intent(this, com.android.sliderview.MainActivity.class); startActivity(i); 

But I get null, it looks in the module when debugging:

 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(layout.activity_main); this.btnFlip = (ImageButton)this.findViewById(id.btnFlip); // btnFlip: null this.btnQrCode = (ImageButton)this.findViewById(id.btnQr); // btnQrCode: null 
  • one
    Name another layer. - Suvitruf
  • AND!!!!!! THIS is the correct answer! This guy gets a medal! Thank! So much tormented, and the business! But why? Conflict? SENX! - Bogdan Shulga
  • one
    It is hard to say. I'd expect a mistake to be. It is strange that it does not issue warnings. - Suvitruf

1 answer 1

Most likely the activity_main layer from the application overlaps the activity_main from the module.

Need to rename.