pushbullet服务不起作用

时间:2014-11-17 19:37:38

标签: android

对于我的应用程序,我使用pushbullet将推送消息发送到我的设备。在这个设备上,我有一个应该显示此消息的应用程序。因此我使用了pushbullet - API,如下所述:https://docs.pushbullet.com/extensions/messaging/guide/ 所以我在我的清单文件中添加了一个服务并实现了一个类,它只应该编写一条Log消息。

我的清单文件:

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

<uses-permission android:name="com.pushbullet.android.permission.READ_MESSAGING_EXTENSION_DATA" />
<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <service
        android:name=".SampleMessagingExtension"
        android:permission="com.pushbullet.android.permission.READ_MESSAGING_EXTENSION_DATA">
        <intent-filter>
            <action android:name="com.pushbullet.android.extension.MessagingExtension" />
        </intent-filter>
        <meta-data
            android:name="protocolVersion"
            android:value="1" />
    </service>
</application>
</manifest>

我的基本活动,只显示“Hello World”

package com.example.stfgorbitzapp;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
}
}

我的班级,应该在收到意图时执行:

package com.example.stfgorbitzapp;

import android.content.Intent;
import android.util.Log;

import com.pushbullet.android.extension.MessagingExtension;

public class SampleMessagingExtension extends MessagingExtension{
private static final String TAG = "SampleMessagingExtension";
@Override

protected void onMessageReceived(final String conversationIden, final String message) {
Log.i(TAG, "Pushbullet MessagingExtension: onMessageReceived(" + conversationIden + ", " + message + ")");
}

@Override
protected void onConversationDismissed(final String conversationIden) {
Log.i(TAG, "Pushbullet MessagingExtension: onConversationDismissed(" + conversationIden + ")");
}

}

但是当我发送推送消息时,我无法读取日志消息。 onyone可以帮助我吗?我忘记了什么吗?即具体权限?

1 个答案:

答案 0 :(得分:0)

也许您还需要网络状态和Wifi权限吗? Pushbullet应该使用网络来交换通知..

关于日志:优先级设置为INFO级别。也许你过滤它们? 你使用的是Android Studio还是Eclipse?

相关问题