How to Auto-start an Android Application?

后端 未结 4 669
花落未央
花落未央 2020-11-27 11:02

I\'m not sure how to autostart an android application after the android emulator completes its booting. Does anyone have any code snippets that will help me?

4条回答
  •  孤城傲影
    2020-11-27 11:34

    Edit your AndroidManifest.xml to add RECEIVE_BOOT_COMPLETED permission

    
    

    Edit your AndroidManifest.xml application-part for below Permission

    
        
            
            
        
    
    

    Now write below in Activity.

    public class BootUpReceiver extends BroadcastReceiver{
        @Override
        public void onReceive(Context context, Intent intent) {
            Intent i = new Intent(context, MyActivity.class);  
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);  
        }
    }
    

提交回复
热议问题