android - Onclick back button the application stops -


i have 1 problem regarding app,when click button application getting finish.i need prevent it.how make .

@override public void onbackpressed() {    log.d("cda", "onbackpressed called");    intent setintent = new intent(intent.action_main);     startactivity(setintent); }  

i have tried this.but not working .actually need when click button ,the application should not finish should run in background.can me out.@thanks

try doing this:

@override public void onbackpressed() {     log.d("cda", "onbackpressed called");     intent intent = new intent();     intent.setaction(intent.action_main);     intent.addcategory(intent.category_home);      startactivity(intent); } 

by doing this, activity not destroyed (i.e. ondestroy not raised). also, there's no guarantee android preserve activity long.

in case, running process want keep on running in background, suggest go service or intentservice.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -