Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Url解析.com Android推送通知_Android_Json_Parse Platform_Push - Fatal编程技术网

使用Url解析.com Android推送通知

使用Url解析.com Android推送通知,android,json,parse-platform,push,Android,Json,Parse Platform,Push,我正在尝试将解析与推送通知集成到我的应用程序中,让通知显示自定义文本,并在向设备发送url时打开设备的浏览器 解析集成很好(这是最简单的部分),但我遇到的问题是如何为集成编写代码,以处理解析接口发送的json代码,并让应用程序将其转换为我需要完成的操作 我知道我必须更新清单文件和主活动类才能完成这项任务,但我被卡住了。将清单添加到 <receiver android:name="com.sample.app.android.recevier.PushNotificationRecevier

我正在尝试将解析与推送通知集成到我的应用程序中,让通知显示自定义文本,并在向设备发送url时打开设备的浏览器

解析集成很好(这是最简单的部分),但我遇到的问题是如何为集成编写代码,以处理解析接口发送的json代码,并让应用程序将其转换为我需要完成的操作

我知道我必须更新清单文件和主活动类才能完成这项任务,但我被卡住了。

将清单添加到

<receiver android:name="com.sample.app.android.recevier.PushNotificationRecevier" >
   <intent-filter>
     <action android:name="com.sample.app.android.SIMPLE_NOTIFICATION" />
   </intent-filter>
</receiver>

好的,我知道了,但不确定在“你的东西”区域放什么。我知道它必须解码json查询(我将研究如何构造,因为我对java和json还不熟悉)。但也会得到以下错误:广播接收器、上下文和意图无法解析为类型。u可以使用JSONObject JSONObject=new JSONObject(Intent.getExtras().getString(“com.parse.Data”);表单获取json对象,然后你可以用自己的方式解析。好的,通过eclipse的大量检查,最终验证了这一点。Nw表示JSON代码。我想能够发送文本和一个推在浏览器中打开的url。在您的代码中,我只看到appID、packageName和versionCode。我可以传递这些,但我应该传递什么来发送自定义标题、文本和url。类似这样的内容:{“title”:“您有一条新消息”,“alert”:“这里有一些文本”,“url”:”}请检查我的答案是否有用好的谢谢更新:)好的,看起来它现在将接受并解析JSON数据,但是需要构建什么构造函数来实际构建通知,以便所有内容都能正确发送?在您的内容下,我将其编辑为:String title=jsonObject.getString(“title”);字符串alert=jsonObject.optString(“alert”);字符串url=jsonObject.optString(“url”);
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"));


        }
    }
}