使用android设置解析推送

时间:2014-03-26 14:29:30

标签: android parsing jar push

我只是尝试用android设置解析,我想我做了 在解析信息页面上写的所有内容。

这似乎是导致错误的行: PushService.setDefaultPushCallback(this, ActivityAppLaunch.class);

这是我试过的: 1. the jar of this class file belongs to container android private libraries 2. Android Runtime and Nullpoint Exceptions

这是我的代码:

ActivityAppLaunch.java

...
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseInstallation;
import com.parse.PushService;

public class ActivityAppLaunch extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // PARSE
    Parse.initialize(this, "XXX", "XXX");
    LINE THAT CAUSES FAIL: PushService.setDefaultPushCallback(this, ActivityAppLaunch.class);                    
    // PARSE END
...

的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pthuermer.juraquiz"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
  IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
  to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
    android:name="com.pthuermer.juraquiz.permission.C2D_MESSAGE" />
<uses-permission android:name="com.pthuermer.juraquiz.permission.C2D_MESSAGE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.pthuermer.juraquiz.ActivityAppLaunch"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.pthuermer.juraquiz.ActivityQuiz"
        android:label="@string/title_activity_activity_quiz"
        android:screenOrientation="portrait" >
    </activity>

    <!-- PARSE -->
    <service android:name="com.parse.PushService" />
    <receiver android:name="com.parse.ParseBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.parse.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <!--
              IMPORTANT: Change "com.parse.starter" to match your app's package name.
            -->
            <category android:name="com.pthuermer.juraquiz" />
        </intent-filter>
    </receiver>
    <!-- PARSE END -->

</application>

这是我收到的:

Source not found
The JAR of this class file belongs to container 'Android Private Libraries' which
does not allow modifications to source attachments on its entries

后面跟着&gt;非常&lt;长错误描述。顺便说一下,我的原木猫里什么都没有!

// Compiled from PushRouter.java (version 1.5 : 49.0, super bit)
class com.parse.PushRouter {

  // Field descriptor #234 Ljava/lang/String;
  private static final java.lang.String TAG = "com.parse.ParsePushRouter";

  // Field descriptor #234 Ljava/lang/String;
  private static final java.lang.String LEGACY_ROUTE_LOCATION = "persistentCallbacks";

  // Field descriptor #234 Ljava/lang/String;
  private static final java.lang.String STATE_LOCATION = "pushState";

  // Field descriptor #239 Ljava/util/concurrent/ExecutorService;
  private static final java.util.concurrent.ExecutorService EXECUTOR;

  // Field descriptor #234 Ljava/lang/String;
  public static final java.lang.String GCM_RECEIVE_ACTION = "com.google.android.c2dm.intent.RECEIVE";

  // Field descriptor #242 I
  static int MAX_HISTORY_LENGTH;

  // Field descriptor #244 Lcom/parse/Task;
  // Signature: Lcom/parse/Task<Ljava/lang/Void;>;
  private static com.parse.Task lastTask;

  // Field descriptor #248 Lcom/parse/PushRouter$PushListener;
  private static com.parse.PushRouter$PushListener pushListener;

  // Field descriptor #250 Lcom/parse/PushRouter;
  private static com.parse.PushRouter instance;

  // Field descriptor #234 Ljava/lang/String;
  private final java.lang.String stateLocation;

  // Field descriptor #253 Lcom/parse/PushRoutes;
  private final com.parse.PushRoutes routes;

  // Field descriptor #255 Lcom/parse/PushHistory;
  private final com.parse.PushHistory history;

  // Field descriptor #257 Ljava/util/concurrent/atomic/AtomicBoolean;
  private final java.util.concurrent.atomic.AtomicBoolean isRefreshingInstallation;

  // Method descriptor #259 (Ljava/lang/String;Ljava/lang/Class;I)Lcom/parse/Task;
  // Signature: (Ljava/lang/String;Ljava/lang/Class<+Landroid/app/Activity;>;I)Lcom/parse/Task<Ljava/lang/Void;>;
  // Stack: 6, Locals: 6
  public static com.parse.Task subscribeAsync(java.lang.String channel, java.lang.Class cls, int iconId);
      0  aload_0 [channel]
      1  ifnull 48
      4  aload_0 [channel]
      5  invokestatic com.parse.PushRoutes.isValidChannelName(java.lang.String) : boolean [4]
      8  ifne 48
     11  new java.lang.IllegalArgumentException [5]
     14  dup
     15  new java.lang.StringBuilder [6]
     18  dup
     19  invokespecial java.lang.StringBuilder() [7]
     22  ldc <String "Invalid channel name: + "> [8]
     24  invokevirtual java.lang.StringBuilder.append(java.lang.String) : java.lang.StringBuilder [9]
     27  aload_0 [channel]
     28  invokevirtual java.lang.StringBuilder.append(java.lang.String) : java.lang.StringBuilder [9]
     31  ldc <String " (must be empty "> [10]
     33  invokevirtual java.lang.StringBuilder.append(java.lang.String) : java.lang.StringBuilder [9]
     36  ldc <String "string or a letter followed by alphanumerics or hyphen)"> [11]
     38  invokevirtual java.lang.StringBuilder.append(java.lang.String) : java.lang.StringBuilder [9]
     41  invokevirtual java.lang.StringBuilder.toString() : java.lang.String [12]
     44  invokespecial java.lang.IllegalArgumentException(java.lang.String) [13]
     47  athrow
     48  aload_1 [cls]
     49  ifnonnull 62
     52  new java.lang.IllegalArgumentException [5]
     55  dup
     56  ldc <String "Can't subscribe to channel with null activity class."> [14]
     58  invokespecial java.lang.IllegalArgumentException(java.lang.String) [13]
     61  athrow
     62  iload_2 [iconId]
     63  ifne 76
     66  new java.lang.IllegalArgumentException [5]
     69  dup
     70  ldc <String "Must subscribe to channel with a valid icon identifier."> [15]
     72  invokespecial java.lang.IllegalArgumentException(java.lang.String) [13]
     75  athrow
     76  aconst_null
     77  astore_3 [subscribeTask]
     78  ldc_w <Class com.parse.PushRouter> [16]
     81  dup
     82  astore 4
     84  monitorenter
     85  invokestatic com.parse.PushRouter.getLastTask() : com.parse.Task [17]
     88  new com.parse.PushRouter$1 [18]
     91  dup
     92  aload_0 [channel]
     93  aload_1 [cls]
     94  iload_2 [iconId]
     95  invokespecial com.parse.PushRouter$1(java.lang.String, java.lang.Class, int) [19]
     98  getstatic com.parse.PushRouter.EXECUTOR : java.util.concurrent.ExecutorService [20]
    101  invokevirtual com.parse.Task.onSuccess(com.parse.Continuation, java.util.concurrent.Executor) : com.parse.Task [21]
    104  astore_3 [subscribeTask]
    105  aload_3 [subscribeTask]
    106  invokestatic com.parse.PushRouter.makeUnhandledExceptionsFatal(com.parse.Task) : com.parse.Task [22]
    109  putstatic com.parse.PushRouter.lastTask : com.parse.Task [23]
    112  aload 4
    114  monitorexit
    115  goto 126
    118  astore 5
    120  aload 4
    122  monitorexit
    123  aload 5
    125  athrow
    126  aload_3 [subscribeTask]
    127  areturn
      Exception Table:
        [pc: 85, pc: 115] -> 118 when : any
        [pc: 118, pc: 123] -> 118 when : any
      Line numbers:
        [pc: 0, line: 57]
        [pc: 11, line: 58]
        [pc: 48, line: 60]
        [pc: 52, line: 61]
        [pc: 62, line: 62]
        [pc: 66, line: 63]
        [pc: 76, line: 66]
        [pc: 78, line: 68]
        [pc: 85, line: 69]
        [pc: 105, line: 77]
        [pc: 112, line: 78]
        [pc: 126, line: 80]
      Local variable table:
        [pc: 0, pc: 128] local: channel index: 0 type: java.lang.String
        [pc: 0, pc: 128] local: cls index: 1 type: java.lang.Class
        [pc: 0, pc: 128] local: iconId index: 2 type: int
        [pc: 78, pc: 128] local: subscribeTask index: 3 type: com.parse.Task
      Local variable type table:
        [pc: 0, pc: 128] local: cls index: 1 type: java.lang.Class<? extends android.app.Activity>
        [pc: 78, pc: 128] local: subscribeTask index: 3 type: com.parse.Task<java.lang.Void>

  // Method descriptor #272 (Ljava/lang/String;)Lcom/parse/Task;
  // Signature: (Ljava/lang/String;)Lcom/parse/Task<Ljava/lang/Void;>;
  // Stack: 4, Locals: 4
  public static com.parse.Task unsubscribeAsync(java.lang.String channel);
     0  aconst_null
     1  astore_1 [unsubscribeTask]
     2  ldc_w <Class com.parse.PushRouter> [16]
     5  dup
     6  astore_2
     7  monitorenter
     8  invokestatic com.parse.PushRouter.getLastTask() : com.parse.Task [17]
    11  new com.parse.PushRouter$2 [24]
    14  dup
    15  aload_0 [channel]
    16  invokespecial com.parse.PushRouter$2(java.lang.String) [25]
    19  getstatic com.parse.PushRouter.EXECUTOR : java.util.concurrent.ExecutorService [20]
    22  invokevirtual com.parse.Task.onSuccess(com.parse.Continuation, java.util.concurrent.Executor) : com.parse.Task [21]
    25  astore_1 [unsubscribeTask]
    26  aload_1 [unsubscribeTask]
    27  invokestatic com.parse.PushRouter.makeUnhandledExceptionsFatal(com.parse.Task) : com.parse.Task [22]
    30  putstatic com.parse.PushRouter.lastTask : com.parse.Task [23]
    33  aload_2
    34  monitorexit
    35  goto 43
    38  astore_3
    39  aload_2
    40  monitorexit
    41  aload_3
    42  athrow
    43  aload_1 [unsubscribeTask]
    44  areturn
      Exception Table:
        [pc: 8, pc: 35] -> 38 when : any
        [pc: 38, pc: 41] -> 38 when : any
      Line numbers:
        [pc: 0, line: 88]
        [pc: 2, line: 90]
        [pc: 8, line: 91]
        [pc: 26, line: 99]
        [pc: 33, line: 100]
        [pc: 43, line: 102]
      Local variable table:
        [pc: 0, pc: 45] local: channel index: 0 type: java.lang.String
        [pc: 2, pc: 45] local: unsubscribeTask index: 1 type: com.parse.Task
      Local variable type table:
        [pc: 2, pc: 45] local: unsubscribeTask index: 1 type: com.parse.Task<java.lang.Void>

  // Method descriptor #276 (Z)Lcom/parse/Task;
  // Signature: (Z)Lcom/parse/Task<Ljava/util/Set<Ljava/lang/String;>;>;
  // Stack: 4, Locals: 4
  public static com.parse.Task getSubscriptionsAsync(boolean includeDefaultRoute);
     0  aconst_null
     1  astore_1 [getSubscriptionsTask]
     2  ldc_w <Class com.parse.PushRouter> [16]
     5  dup
     6  astore_2
     7  monitorenter
     8  invokestatic com.parse.PushRouter.getLastTask() : com.parse.Task [17]
    11  new com.parse.PushRouter$3 [26]
    14  dup
    15  iload_0 [includeDefaultRoute]
    16  invokespecial com.parse.PushRouter$3(boolean) [27]
    19  getstatic com.parse.PushRouter.EXECUTOR : java.util.concurrent.ExecutorService [20]
    22  invokevirtual com.parse.Task.onSuccess(com.parse.Continuation, java.util.concurrent.Executor) : com.parse.Task [21]
    25  astore_1 [getSubscriptionsTask]
    26  aload_1 [getSubscriptionsTask]
    27  invokevirtual com.parse.Task.makeVoid() : com.parse.Task [28]
    30  invokestatic com.parse.PushRouter.makeUnhandledExceptionsFatal(com.parse.Task) : com.parse.Task [22]
    33  putstatic com.parse.PushRouter.lastTask : com.parse.Task [23]
    36  aload_2
    37  monitorexit
    38  goto 46
    41  astore_3
    42  aload_2
    43  monitorexit
    44  aload_3
    45  athrow
    46  aload_1 [getSubscriptionsTask]
    47  areturn
      Exception Table:
        [pc: 8, pc: 38] -> 41 when : any
        [pc: 41, pc: 44] -> 41 when : any
      Line numbers:
        [pc: 0, line: 111]
        [pc: 2, line: 113]
        [pc: 8, line: 114]
        [pc: 26, line: 121]
        [pc: 36, line: 122]
        [pc: 46, line: 124]
      Local variable table:
        [pc: 0, pc: 48] local: includeDefaultRoute index: 0 type: boolean
        [pc: 2, pc: 48] local: getSubscriptionsTask index: 1 type: com.parse.Task
      Local variable type table:
        [pc: 2, pc: 48] local: getSubscriptionsTask index: 1 type: com.parse.Task<java.util.Set<java.lang.String>>

  // Method descriptor #283 ()Lcom/parse/Task;
  // Signature: ()Lcom/parse/Task<Lorg/json/JSONObject;>;
  // Stack: 3, Locals: 3
  public static com.parse.Task getPushRequestJSONAsync();
     0  aconst_null
     1  astore_0 [getPushRequestTask]
     2  ldc_w <Class com.parse.PushRouter> [16]
     5  dup
     6  astore_1
     7  monitorenter
     8  invokestatic com.parse.PushRouter.getLastTask() : com.parse.Task [17]
    11  new com.parse.PushRouter$4 [29]
    14  dup
    15  invokespecial com.parse.PushRouter$4() [30]
    18  getstatic com.parse.PushRouter.EXECUTOR : java.util.concurrent.ExecutorService [20]
    21  invokevirtual com.parse.Task.onSuccess(com.parse.Continuation, java.util.concurrent.Executor) : com.parse.Task [21]
    24  astore_0 [getPushRequestTask]
    25  aload_0 [getPushRequestTask]
    26  invokevirtual com.parse.Task.makeVoid() : com.parse.Task [28]
    29  invokestatic com.parse.PushRouter.makeUnhandledExceptionsFatal(com.parse.Task) : com.parse.Task [22]
    32  putstatic com.parse.PushRouter.lastTask : com.parse.Task [23]
    35  aload_1
    36  monitorexit
    37  goto 45
    40  astore_2
    41  aload_1
    42  monitorexit
    43  aload_2
    44  athrow
    45  aload_0 [getPushRequestTask]
    46  areturn
      Exception Table:
        [pc: 8, pc: 37] -> 40 when : any
        [pc: 40, pc: 43] -> 40 when : any
      Line numbers:
        [pc: 0, line: 131]
        [pc: 2, line: 133]
        [pc: 8, line: 134]
        [pc: 25, line: 141]
        [pc: 35, line: 142]
        [pc: 45, line: 144]
      Local variable table:
        [pc: 2, pc: 47] local: getPushRequestTask index: 0 type: com.parse.Task
      Local variable type table:
        [pc: 2, pc: 47] local: getPushRequestTask index: 0 type: com.parse.Task<org.json.JSONObject>

  // Method descriptor #288 (Landroid/content/Intent;)Z
  // Stack: 2, Locals: 1
  public static boolean isGcmPushIntent(android.content.Intent intent);
     0  aload_0 [intent]
     1  ifnull 20
     4  ldc <String "com.google.android.c2dm.intent.RECEIVE"> [31]
     6  aload_0 [intent]
     7  invokevirtual android.content.Intent.getAction() : java.lang.String [32]
    10  invokevirtual java.lang.String.equals(java.lang.Object) : boolean [33]
    13  ifeq 20
    16  iconst_1
    17  goto 21
    20  iconst_0
    21  ireturn
      Line numbers:
        [pc: 0, line: 151]
      Local variable table:
        [pc: 0, pc: 22] local: intent index: 0 type: android.content.Intent

  // Method descriptor #292 (Landroid/content/Intent;)V
  // Stack: 5, Locals: 2
  public static void handleGcmPushIntent(android.content.Intent intent);
     0  new java.util.concurrent.Semaphore [34]
     3  dup
     4  iconst_0
     5  invokespecial java.util.concurrent.Semaphore(int) [35]
     8  astore_1 [done]
     9  getstatic com.parse.PushRouter.EXECUTOR : java.util.concurrent.ExecutorService [20]
    12  new com.parse.PushRouter$5 [36]
    15  dup
    16  aload_0 [intent]
    17  aload_1 [done]
    18  invokespecial com.parse.PushRouter$5(android.content.Intent, java.util.concurrent.Semaphore) [37]
    21  invokeinterface java.util.concurrent.ExecutorService.submit(java.lang.Runnable) : java.util.concurrent.Future [38] [nargs: 2]
    26  pop
    27  aload_1 [done]
    28  invokevirtual java.util.concurrent.Semaphore.acquireUninterruptibly() : void [39]
    31  return
      Line numbers:
        [pc: 0, line: 158]
        [pc: 9, line: 159]
        [pc: 27, line: 167]
        [pc: 31, line: 168]
      Local variable table:
        [pc: 0, pc: 32] local: intent index: 0 type: android.content.Intent
        [pc: 9, pc: 32] local: done index: 1 type: java.util.concurrent.Semaphore

  // Method descriptor #296 (Lorg/json/JSONObject;)Lcom/parse/Task;
  // Signature: (Lorg/json/JSONObject;)Lcom/parse/Task<Ljava/lang/Void;>;
  // Stack: 4, Locals: 4
  public static com.parse.Task handlePpnsPushAsync(org.json.JSONObject pushPayload);
     0  aconst_null
     1  astore_1 [receivedPushTask]
     2  ldc_w <Class com.parse.PushRouter> [16]
     5  dup
     6  astore_2
     7  monitorenter
     8  invokestatic com.parse.PushRouter.getLastTask() : com.parse.Task [17]
    11  new com.parse.PushRouter$6 [40]
    14  dup
    15  aload_0 [pushPayload]
    16  invokespecial com.parse.PushRouter$6(org.json.JSONObject) [41]
    19  getstatic com.parse.PushRouter.EXECUTOR : java.util.concurrent.ExecutorService [20]

...

     inner name: #231 HandlePushResult, accessflags: 16408 static final],
    [inner class info: #165 com/parse/PushRouter$10, outer class info: #0
     inner name: #0, accessflags: 0 default],
    [inner class info: #55 com/parse/PushRouter$9, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #45 com/parse/PushRouter$8, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #42 com/parse/PushRouter$7, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #40 com/parse/PushRouter$6, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #36 com/parse/PushRouter$5, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #29 com/parse/PushRouter$4, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #26 com/parse/PushRouter$3, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #24 com/parse/PushRouter$2, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #18 com/parse/PushRouter$1, outer class info: #0
     inner name: #0, accessflags: 8 static],
    [inner class info: #143 com/parse/PushRoutes$Route, outer class info: #64 com/parse/PushRoutes
     inner name: #387 Route, accessflags: 25 public static final]
}

1 个答案:

答案 0 :(得分:1)

解决: 需要设置<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 在AndroidManifest.xml中允许PushRouter访问。