android 发送通知栏消息,点击后打开指定网页
2013-07-05 17:08
519 查看
package com.eboy.testnotification;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
private static final String edtShortTitle = "edtShortTitle";
private static final String edtTitle = "edtTitle";
private static final String edtContent = "http://www.985dy.com";
@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_error;
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;
}
}
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
private static final String edtShortTitle = "edtShortTitle";
private static final String edtTitle = "edtTitle";
private static final String edtContent = "http://www.985dy.com";
@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_error;
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;
}
}
相关文章推荐
- android 发送通知栏消息,点击后打开指定网页
- Android----Intent,运用由android系统帮助匹配实现打电话、发送短信、打开网页、播放音乐、打开视频、打开图片、安装APK、通知栏消息、拍照上传头像等功能
- Android在APP存活或者被杀死情况下,点击通知栏打开指定Activity
- Android 点击通知栏消息 跳转到指定的Fragment界面
- 【Android开发那点破事】消息推送BroadcastReceiver,点击通知打开两次Activity问题
- android 点击通知栏消息打开activity,如果app未运行先启动app或打开activity返回后再启动app
- Android JPush (通讯录好友,是该应用app,则发送一条提示消息,点击通知,跳进对应的页面)
- Android点击通知栏消息,仅打开App,不跳转到具体Activity
- Android 点击通知栏消息 跳转到指定的Fragment界面
- Android中Webview打开网页的同时发送HTTP头信息方法
- iOS 点击通知栏消息跳转到指定的页面
- Android实现点击通知栏后,先启动应用再打开目标Activity
- Android实现点击通知栏后,先启动应用再打开目标Activity ,极光推送等推送的也可以参考一下(转)
- Android实现点击通知栏后,先启动应用再打开目标Activity
- 点击TextView浏览器打开指定网页
- 在android中,如何用指定的浏览器打开某网页?
- Android点击通知栏,打开应用跳转到相应的Activity
- Android获取本机浏览器包名,并调用指定浏览器打开网页
- Android实现点击通知栏后,先启动应用再打开目标Activity 144
- Android在网页下(WebView中运用HTML)点击按钮打开本地手机应用程序