请教,如何点击通知qq验证消息有事请教你打开应用后跳转到特定URL

匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。实现功能:短信内容中含有url(例如,/app/),点击后打开apk遗留问题:点击url后,会出现选择框,让用户选择是用浏览器打开还是用该apk打开————没有找到方法如何不出现该选择框??参考: 1、应用中AndroidManifest.xml配置——主要&?xml version="1.0" encoding="utf-8"?& xmlns:android="/apk/res/android"
package="com.example.msgintenapptest"
android:versionCode="1"
android:versionName="1.0"
android:minSdkVersion="8"
android:targetSdkVersion="19"
android:name="android.permission.SEND_SMS"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name=".MainActivity"
android:label="@string/app_name"
android:name="android.intent.action.MAIN"
android:name="android.intent.category.LAUNCHER"
android:scheme="http"
android:host=""
android:pathPrefix="/app/"
android:name="android.intent.action.VIEW"
android:name="android.intent.category.DEFAULT"
android:name="android.intent.category.BROWSABLE"
2、测试发送短信
private Button.OnClickListener button_clickListener = new Button.OnClickListener(){
public void onClick(View v) {
URL url = new URL("/app/");
intentToSms("",url.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
private void intentToSms(String tel, String msg){
Uri uri = Uri.parse("smsto:"+tel);
Intent intent = new Intent(Intent.ACTION_SENDTO,uri);
intent.putExtra("sms_body", msg);
startActivity(intent);
阅读(...) 评论()(浅谈)Jpush推送通知点击跳转到具体界面 - 博客频道 - CSDN.NET
道可道,非常道
丈夫在世当有为 ,为民播下太平春。
分类:札记Android
(好记性,不如烂笔头)
&&& Android端接入Jpush推送后,遇见的一个小问题:“假如有多条推送的通知推送过来后,点击任意一条所获得的Intent传输所需数据,都变成了最后一条通知的数据”。网上对这块貌似没有好的解决方案,下面解决方案给大家献丑一下,以备不时之需。
if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Map&String,String& map = new ArrayMap&String,String&();
for (String key : bundle.keySet()) {
if (key.equals(JPushInterface.EXTRA_EXTRA)) {
if (bundle.getString(JPushInterface.EXTRA_EXTRA).isEmpty()) {
JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
Iterator&String& it =
json.keys();
while (it.hasNext()) {
String myKey = it.next().toString();
map.put(myKey, json.getString(myKey));
} catch (JSONException e) {
Bundle bundle = new Bundle();
bundle.putString(&taskId& , map.get(&taskId&));
if(&1&.equals(map.get(&type&))){
Intent i = new Intent(context, 跳转的Activity);
i.putExtras(bundle);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}else if(&2&.equals(map.get(&type&))){
Intent i = new Intent(context, 跳转的Activity);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtras(bundle);
context.startActivity(i);
}这里示例是根据json数据获取“type”和“taskId”两个字段,并根据type类型跳转到具体界面,传输相应的taskId。看起来很高大上的实现,通过迭代器和集合两个重点技术,这是我同事的解决方案,在我面前得瑟后,我感觉有问题,这种方法完全就是多余。我们可能会模糊JPush官方文档的概念:
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Log.d(TAG, &onReceive - & + intent.getAction());
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
}else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
System.out.println(&收到了自定义消息。消息内容是:& + bundle.getString(JPushInterface.EXTRA_MESSAGE));
// 自定义消息不会展示在通知栏,完全要开发者写代码去处理
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
System.out.println(&收到了通知&);
// 在这里可以做些统计,或者做些其他工作
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
System.out.println(&用户点击打开了通知&);
// 在这里可以自己写代码去定义用户点击后的行为
Intent i = new Intent(context, TestActivity.class);
//自定义打开的界面
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Log.d(TAG, &Unhandled intent - & + intent.getAction());
}傻瓜式思维可能导致我们以为只有在判断getAction为收到通知时才能获取数据的僵局,其实JPush的技术大神们早就在我们进行点击后,会将具体数据传输给我们来处理,这不同于IOS的APNs机制,只是一个通知而已。所以,优化后的就是:
if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Bundle bundle = intent.getExtras();
String s = bundle.getString(JPushInterface.EXTRA_EXTRA);
JSONObject obj = new JSONObject(s);
taskId = obj.getString(&taskId&);
type = obj.getString(&type&);
}catch(JSONException e){
// 在这里可以自己写代码去定义用户点击后的行为
Bundle bundle2 = new Bundle();
bundle2.putString(&taskId& , taskId);
if(&1&.equals(type)){
Intent i = new Intent(context, VideoTaskDetailActivity.class);
//自定义打开的界面
i.putExtras(bundle2);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}else if(&2&.equals(type)){
Intent i = new Intent(context, TaskDetailActivity.class);
//自定义打开的界面
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtras(bundle2);
context.startActivity(i);
定义的全局变量taskId和type是问题出现的关键,总结起来就一句话:在if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction()))判断处理所有逻辑就行了。
crazywolfteam
排名:千里之外
(6)(0)(5)(1)android 发送通知栏消息,点击后打开指定网页 - jxgxy - 博客园
随笔 - 260, 文章 - 0, 评论 - 73, 引用 - 1
package&com.eboy.import&android.app.Aimport&android.app.Nimport&android.app.NotificationMimport&android.app.PendingIimport&android.content.Cimport&android.content.Iimport&android.net.Uimport&android.os.Bimport&android.view.Mimport&android.view.Vpublic&class&MainActivity&extends&Activity&{&&&&private&static&final&String&edtShortTitle&=&"edtShortTitle";&&&&private&static&final&String&edtTitle&=&"edtTitle";&&&&private&static&final&String&edtContent&=&"";&&&&@Override&&&&public&void&onCreate(Bundle&savedInstanceState)&{&&&&&&&&super.onCreate(savedInstanceState);&&&&&&&&setContentView(R.layout.activity_main);&&&&}&&&&&&&&public&void&sendNotification1(View&v){&&&&&&&&int&icon&=&android.R.drawable.stat_notify_&&&&&&&&Notification&notification&=&new&Notification(icon,&edtShortTitle,&System.currentTimeMillis());&&&&&&&&Intent&intent&=&new&Intent(Intent.ACTION_VIEW,&Uri.parse(edtContent));&&&&&&&&&&&&&&&&PendingIntent&pendingIntent&=&PendingIntent.getActivity(this,&0,&intent,&0);&&&&&&&&&&&&&&&&notification.setLatestEventInfo(this,&edtTitle,&edtContent,&pendingIntent);&&&&&&&&&&&&notification.defaults&=&Notification.DEFAULT_SOUND;&&&&&&&&notification.flags&=&Notification.FLAG_NO_CLEAR&|&Notification.FLAG_AUTO_CANCEL;&//不可清除,自动取消&&&&&&&&&NotificationManager&notificationManager&=&(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);&&&&&&&&notificationManager.notify(100,&notification);&&&&}&&&&@Override&&&&public&boolean&onCreateOptionsMenu(Menu&menu)&{&&&&&&&&getMenuInflater().inflate(R.menu.activity_main,&menu);&&&&&&&&&&&&&&&&return&true;&&&&}}

我要回帖

更多关于 点击推送消息跳转页面 的文章

 

随机推荐