android Notification 程式碼備份
package com.example.notification;
import android.os.Bundle;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.support.v4.app.NavUtils;
public class MainActivity extends Activity {
private Notification n;
private NotificationManager nm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String service = NOTIFICATION_SERVICE;
nm = (NotificationManager)getSystemService(service);
n = new Notification();
int icon = n.icon = R.drawable.jump;
String tickerText = "TestNotification";
long when = System.currentTimeMillis();
n.icon = icon;
n.tickerText = tickerText;
n.when = when;
Button btn1 = (Button)findViewById(R.id.button1);
Button btn2 = (Button)findViewById(R.id.button2);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this,MainActivity.class);
PendingIntent pi = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
MainActivity.this.n.setLatestEventInfo(MainActivity.this, "My Title", "My Content", pi);
nm.notify(0,n);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
nm.cancel(0);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
import android.os.Bundle;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.support.v4.app.NavUtils;
public class MainActivity extends Activity {
private Notification n;
private NotificationManager nm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String service = NOTIFICATION_SERVICE;
nm = (NotificationManager)getSystemService(service);
n = new Notification();
int icon = n.icon = R.drawable.jump;
String tickerText = "TestNotification";
long when = System.currentTimeMillis();
n.icon = icon;
n.tickerText = tickerText;
n.when = when;
Button btn1 = (Button)findViewById(R.id.button1);
Button btn2 = (Button)findViewById(R.id.button2);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this,MainActivity.class);
PendingIntent pi = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
MainActivity.this.n.setLatestEventInfo(MainActivity.this, "My Title", "My Content", pi);
nm.notify(0,n);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
nm.cancel(0);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
相關文章
- Android Notification通知欄的必備姿勢Android
- Android 《Notification》Android
- Windows下RMAN備份程式碼Windows
- SQL備份資料庫程式碼SQL資料庫
- SQL Server 簡單備份指令碼程式碼SQLServer指令碼
- rman備份和增量備份指令碼指令碼
- gerrit程式碼簡單備份方案分享
- Xtrabackup每週增量備份指令碼程式指令碼
- SVN程式碼管理 備份與還原
- 備份ABAP程式碼 (分模組儲存)
- DRF序列化器程式碼備份
- Android中的NotificationAndroid
- Android Notification 詳解Android
- Android 通知之 NotificationAndroid
- android之Notification通知Android
- 備份指令碼指令碼
- Android8.1 SystemUI原始碼分析之 Notification流程AndroidSystemUI原始碼
- 使用 GitHub Actions 自動備份程式碼倉Github
- 9路棋盤識別-程式碼備份
- Android O 新特性 — NotificationAndroid
- Android通知Notification全面剖析Android
- Android Notification 通知詳解Android
- MySQL備份之分庫分表備份指令碼MySql指令碼
- mysqldump備份不輸入密碼直接備份MySql密碼
- Oracle冷備份(一致備份)指令碼Oracle指令碼
- ORACLE備份指令碼Oracle指令碼
- mysqldump 備份指令碼MySql指令碼
- rman 備份指令碼指令碼
- mysqldump備份指令碼MySql指令碼
- innobackupex備份指令碼指令碼
- SQLServer備份指令碼SQLServer指令碼
- SQL 備份指令碼SQL指令碼
- Mongodb 備份指令碼MongoDB指令碼
- rman備份指令碼指令碼
- oracle 備份指令碼Oracle指令碼
- mysql備份指令碼MySql指令碼
- Android程式保活(二):利用 Notification 提升許可權Android
- SqlServer NBU備份出現錯誤程式碼2SQLServer