내 앱의 경우 pushbullet을 사용하여 푸시 메시지를 내 기기에 보냅니다. 이 기기에는이 메시지가 표시되어야하는 앱이 있습니다. 따라서 여기에 설명 된 pushbullet-API를 사용합니다. https://docs.pushbullet.com/extensions/messaging/guide/ 그래서 내 매니페스트 파일에 서비스를 추가하고 로그 메시지 만 작성해야하는 클래스를 구현했습니다.pushbullet 서비스가 작동하지 않습니다.
내 매니페스트 파일 :
<?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>
내 기본 활동 만 의도를 수신 할 때
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 + ")");
}
}
을
하지만 푸시 메시지를 보내면 로그 메시지를 읽을 수 없습니다. 나를 도와 줄 수 있을까? 내가 뭔가 잊었 니? 나는. 특정 사용 권한?
아니요,이 코드는 도움이되지 않습니다 ... –
SampleMessagingExtension 객체를 만드는 코드는 무엇입니까? – mattd
매니페스트에 정의 된 서비스에서 생성 될 것이라고 생각했습니다. –