当前位置:操作系统 > 安卓/Android >>

ACTIVITY开机自动运行

------------BootBroadcastReceiver .java
package youbanwang.co.cc;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootBroadcastReceiver extends BroadcastReceiver {
  final static String ACTION =

"android.intent.action.BOOT_COMPLETED";


 @Override
 public void onReceive(Context arg0, Intent arg1) {
  // TODO Auto-generated method stub
  if (arg1.getAction().equals(ACTION)) {
   Intent splash=new Intent

(arg0,Splash.class);
   splash.addFlags

(Intent.FLAG_ACTIVITY_NEW_TASK);
   arg0.startActivity(splash);

  
  }
 }

}

 

--------manifest.xml


  <activity

android:name="net.youmi.android.appoffers.YoumiOffersActivity"
     

android:configChanges="keyboard|keyboardHidden|orientation"/>
    

<receiver android:name=".BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
        
    </application>


<uses-permission

android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses

-permission>

 

 

摘自 gongzibai的专栏

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,