如果我是从receiver里面 启动activity 应该怎么做?
------解决方案--------------------
<receiver android:name="com.monetware.android.StartupIntentReceiver"> //指定启动类
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" android:path="com.monetware.android" />
</intent-filter>
</receiver>
public class StartupIntentReceiver extends BroadcastReceiver { //爱先启动什么就什么 private static final String TAG = "StartupIntentReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.info(TAG, "onReceive");
// Intent serviceIntent = new Intent(); //启动Service
// serviceIntent.setAction("com.monetware.android.services.AutoSyncService");
// context.startService(serviceIntent);
Intent intent2=new Intent(context,AndroidLoadingScreen.class); //启动第一个activity
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent2);
}
}
------解决方案--------------------
Android应用可以是单独的模块,比如只有Activity,Service,Receiver等
只要在AndroidManifest.xml中注册了,系统就会识别
对于Activity就不说啦
Receiver,可以静态注册也可以动态注册广播,广播类型可以是自定义类型也可以是系统广播,
比如2楼所写的是通过开机启动广播启动Activity
Service,同理,Manifest.xml注册,通过广播等都可以启动
楼主多看看吧...