我的最後一個話題:How to finish activity in broadcastreceiver onCallEnded()NullPointerExeption而開始新的活動
試着繼續監聽器IncomingCallActivity,所以編輯IcomingCallReceiver到:
public class IncomingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, IncomingCallActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i); }
現在越來越NullPointerExeption開始新的活動時......任何想法,爲什麼?
logcat的
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at IncomingCallActivity.onCreate(IncomingCallActivity.java:34)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
... 11 more
有了這個代碼:
公共類IncomingCallReceiver擴展廣播接收器{
@Override
public void onReceive(Context context, Intent intent) {
SipAudioCall incomingCall = null;
try {
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
...
@Override
public void onCallEnded(SipAudioCall call) {
// IncomingCallActivity.finish();
}
};
Main mainActivity = (Main) context;
incomingCall = mainActivity.manager.takeAudioCall(intent, listener);
mainActivity.call = incomingCall;
Intent i = new Intent(context, IncomingCallActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
活動盯着不困難,但我需要移動偵聽器,以IncomingCallActivity
你可以請更新你所得到的logcat錯誤信息。 – pyus13
發佈您的IncomingCallActivity活動代碼 –
在第34行的IncomingCallActivity.java中存在問題 - 顯示它 – Viacheslav