Android:状态栏Notification
2016-01-05 11:20
405 查看
public class MainActivity extends Activity {
private EditText shorttitleText;
private EditText titleText;
private EditText contentText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
shorttitleText = (EditText) this.findViewById(R.id.shorttitle);
titleText = (EditText) this.findViewById(R.id.title);
contentText = (EditText) this.findViewById(R.id.content);
}
public void send(View v){
String tickerText = shorttitleText.getText().toString();
String title = titleText.getText().toString();
String content = contentText.getText().toString();
int icon = android.R.drawable.stat_notify_chat;
Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:194949494"));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 10, intent, 0);
notification.setLatestEventInfo(this, title, content, pendingIntent);
notification.defaults = Notification.DEFAULT_SOUND;
notification.flags = Notification.FLAG_AUTO_CANCEL;
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(100, notification);
}
}
private EditText shorttitleText;
private EditText titleText;
private EditText contentText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
shorttitleText = (EditText) this.findViewById(R.id.shorttitle);
titleText = (EditText) this.findViewById(R.id.title);
contentText = (EditText) this.findViewById(R.id.content);
}
public void send(View v){
String tickerText = shorttitleText.getText().toString();
String title = titleText.getText().toString();
String content = contentText.getText().toString();
int icon = android.R.drawable.stat_notify_chat;
Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:194949494"));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 10, intent, 0);
notification.setLatestEventInfo(this, title, content, pendingIntent);
notification.defaults = Notification.DEFAULT_SOUND;
notification.flags = Notification.FLAG_AUTO_CANCEL;
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(100, notification);
}
}
相关文章推荐
- Android文件读写注意点
- android studio中的极光推送
- Android编程解析XML方法详解(SAX,DOM与PULL)
- Android夜间模式最佳实践
- android studio 下的debug模式下的keystore变成自己的keystore
- android:windowSoftInputMode属性详解
- Android实现通知栏透明的方法
- Android Studio中如何跳到某一个方法
- Android 自定义View (一)
- 关于android studio 下获取签名文件SHA1的方法
- Android单元测试
- Android API Level 对应关系 6.0
- android preferences使用
- android 自定义TextView中Html超链接点击事件详解
- Android编程中的消息机制实例详解
- android 获取当前程序路径
- android 遇到过的bug(累积文)
- Android sdk下载链接
- Android 环信录音弹出"权限管理"问题
- 查看当前android设备已安装的第三方包