为什么我会收到错误?如何将此方法/类中的信息传递给我的其他类?推送器类/代码正确地获取数据并正确显示,但是当我尝试从另一个类访问其他方法时,它给出了下面的错误。有任何想法吗? 这是我的推送代码,没有类Handler_Pusher:
privatechannel.bind("event", new PrivateChannelEventListener() {
@Override
public void onEvent(final String channelName, final String eventName, final String data) {
Log.v(TAG, "Private Test onEvent: " + channelName + " " + eventName + " " + data);
docSyncData = getDocumentUrlExtension(data);
final String URL = DOCUMENT_URL_PREFIX + docSyncData + ".pdf";
Log.v(TAG, "URL:::" + URL);
Activity_InCall.dialogLaunch(URL);
}
@Override
public void onSubscriptionSucceeded(String channelName) {
Log.v(TAG, "Private Channel onSubscriptionSucceeded: " + channelName);
}
@Override
public void onAuthenticationFailure(String message, Exception e) {
Log.v(TAG, "Private Channel onAuthenticationFailure: " + message + ":::" + e);
}
});
以下是我试图在类Activity_InCall中调用的方法:
public static void dialogLaunch(String data){
Log.v(TAG, "Pusher:::" + data);
Intent activityDocSync = new Intent(context, Activity_DocSync.class);
context.startActivity(activityDocSync);
}
这是我看到的logcat错误,网址通过确定但是然后给了我" eventQueue"然后进入空指针异常的错误:
11-23 09:58:12.551 19108-19771/com.talkative.reach V/InCallActivity: Pusher:::URL
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: FATAL EXCEPTION: pusher-java-client eventQueue
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: Process: com.talkative.reach, PID: 19108
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at android.content.ComponentName.<init>(ComponentName.java:77)
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at android.content.Intent.<init>(Intent.java:4160)
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at com.talkative.reach.Activity_InCall.dialogLaunch(Activity_InCall.java:398)
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at com.talkative.reach.Handler_PusherPrivate$2.onEvent(Handler_PusherPrivate.java:90)
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at com.pusher.client.channel.impl.ChannelImpl$1.run(ChannelImpl.java:100)
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-23 09:58:12.598 19108-19771/com.talkative.reach E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818)