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的專欄

發佈留言