i want to choose between two xml files when the application starts i.e in onCreate().
For example say i am reading the battery status when the app opens, if its less then some level i should display a warning message or the start activity of the app. Is this feasible???? If there is any way, can i get some help????
my code
isSDCard = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
super.onCreate(savedInstanceState);
if(isSDCard)
{
Intent intent = new Intent(Activity.this,SDcard.class);
startActivity(intent);
finish();
//setContentView(R.layout.missing_sd);
}
else{
//Intent intent = new Intent(this,ImageSelection.class);
//startActivity(intent);
// finish();
setContentView(R.layout.image_menu);
}
}
my SDcard.class
public class SDcard extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.missing_sd);
// Button inserted_card = (Button) findViewById(R.id.button_insert);
// inserted_card.setOnClickListener(new OnClickListener() {
//public void onClick(View v) {
// Toast.makeText(getApplicationContext(), "Card Inserted!!!", Toast.LENGTH_SHORT).show();
//}
//});
}
}
i commented onclick part to make sure it is not working!!!
Yes, it is possible, for example:
But if you provide different functionality in such cases, wouldn’t it be better to start different activities based on the condition?
For example: