我想从onReceive()BroadcastReceiver方法开始一个Activity,但是每次都会出现一个ActivityNotFound异常。请检查并告诉我代码有什么问题

    <activity android:name="NearbyFriends"></activity>

    <receiver android:name="AlarmManagerBroadcastReceiver"/>


调用另一个Activity的代码是

    Intent intent1 = new Intent();
    Intent1.setClassName("com.android.letscatchupclientside","com.android.letscatchupclientside.NearbyFriends");
    intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent1);

最佳答案

尝试这个

Intent intent1 = new Intent(context, NearbyFriends.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent1);

08-04 02:02