【发布时间】:2014-10-16 11:58:53
【问题描述】:
我正在尝试通过推送通知将解析集成到我的应用程序中,并让通知显示自定义文本并在我向其发送 url 时打开设备的浏览器。
解析集成很好(这是简单的部分),但我卡住的地方是要为集成编写什么代码来处理解析接口发送的 json 代码,并让应用程序将其转换为我需要完成的操作。
我知道我必须更新清单文件和主要活动类才能完成此操作,但我被卡住了。
【问题讨论】:
标签: android json parse-platform push
我正在尝试通过推送通知将解析集成到我的应用程序中,并让通知显示自定义文本并在我向其发送 url 时打开设备的浏览器。
解析集成很好(这是简单的部分),但我卡住的地方是要为集成编写什么代码来处理解析接口发送的 json 代码,并让应用程序将其转换为我需要完成的操作。
我知道我必须更新清单文件和主要活动类才能完成此操作,但我被卡住了。
【问题讨论】:
标签: android json parse-platform push
将清单添加到
<receiver android:name="com.sample.app.android.recevier.PushNotificationRecevier" >
<intent-filter>
<action android:name="com.sample.app.android.SIMPLE_NOTIFICATION" />
</intent-filter>
</receiver>
创建一个接收器类
import org.json.JSONException;
import org.json.JSONObject;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class PushNotificationRecevier extends BroadcastReceiver{
String SimpleNotification="com.sample.app.android.SIMPLE_NOTIFICATION";
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equalsIgnoreCase(SimpleNotification)){
// Your Stuff
JSONObject jsonObject=new JSONObject(intent.getExtras().getString("com.parse.Data"));
}
}
}
【讨论】: