this is my first app and it’s a present for android people in Serbia…i’m not charging it. I finished it, but I have some problems. First problem is:
My first screen is alert dialog where I explained to user’s what thay need to run my app. The problem is when i start my app again when(i guess) is destroyed from android system it dont show alert dialog. It shows an empty screen.I go out on home button come again and now it all okey. What’s wrong??? Any idea?
Second problem is: My classes are all in one folder:src/test/projekat. When i start my app on phone it installs all 4 files which represent my 4 activitys in manifest. Is this the way it should happen??? Thanks a lot…
EDITED ALERT DIALOG CODE:
public class PronadjiKlopuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Kreira AlertDialog sa dva dugmeta koji ce se pojaviti pri aktiviranju aplikacije
AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setTitle("Vasa trenutna lokacija");
ad.setMessage("Da bi ste koristili aplikaciju potrebno je da ukljucite internet konekciju i dozvolite koriscenje GPS satelita i wireless mreze za dobijanje lokacije.");
// ad.setMessage("Da bi ste koristili aplikaciju potrebno je da dozvolite ocitavanje vase trenutne lokacije.");
ad.setButton(DialogInterface.BUTTON_POSITIVE, "Dozvoli", new DialogInterface.OnClickListener() {
//Klikom na dugme Dozvoli otvara se novi prozor
@Override
public void onClick(DialogInterface ad, int which) {
Intent i = new Intent(PronadjiKlopuActivity.this, TrenutnaLokacija.class);
startActivity(i);
}
});
ad.setButton(DialogInterface.BUTTON_NEGATIVE, "Ne dozvoli",new DialogInterface.OnClickListener() {
//Klikom na dugme Ne dozvoli aplikacija se zatvara
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
//Mesto na kojem ce se pojaviti dialog
WindowManager.LayoutParams wMLP = ad.getWindow().getAttributes();
wMLP.x = 100;
wMLP.y = 200;
ad.getWindow().setAttributes(wMLP);
ad.show();
}
//U slucaju pritiska dugmeta Back gasi se aplikacija
@Override
public void onBackPressed() {
// Intent i = new Intent(Intent.ACTION_MAIN);
// i.addCategory(Intent.CATEGORY_HOME);
// startActivity(i);
finish();
super.onBackPressed();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
you have added this property in each of your activity tag in your manifest file:
you should add this property to your activity in manifest which will be first one when your app starts..
for your alertDialog show your code..