編輯:關於Android編程
這樣來寫:
public void onCreate() {
super.onCreate();
ntfmngr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
setNotifyType(R.drawable.logo,"aaaaaaaaaaa",3);
}
private void setNotifyType(int icon, String text, int num) {
Intent notifyIntent = new Intent().setClass(getApplicationContext(),
MainActivity.class);
// notifyIntent.putExtra("mode", mNotifyMode);
notifyIntent.setAction(Constants.UPDATE_HOME_LIST); //根據這個收到的activity可以接受這個action,判斷是什麼類型的消息
// notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
// Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent appIntent = PendingIntent.getActivity(this, 0,
notifyIntent, 0);
Notification myNotification = new Notification();
// myNotification.defaults = Notification.DEFAULT_VIBRATE;
Uri soundUri = Uri
.parse("android.resource://com.sina.weibo/raw/notificationsound");
// Log.e(Constants.TAG, soundUri.getPath());
myNotification.flags = Notification.FLAG_AUTO_CANCEL;
myNotification.icon = icon;
myNotification.defaults = Notification.DEFAULT_SOUND;
myNotification.sound = soundUri; //notication過來的時候有聲音
if (num != -1) {
myNotification.number = num;
}
long[] vb = new long[] { 80, 80 };
myNotification.vibrate = vb;
myNotification.tickerText = text;
myNotification.setLatestEventInfo(this, getString(R.string.app_name),
text, appIntent);
System.out.println("====ntfmngr.notify");
ntfmngr.notify(NOTIFY_MESSAGE, myNotification); //NOTIFY_MESSAGE為notification的key,可以根據key來取消
}
必須加入相應的權限才有震動
可以這樣來取消notication:
if (ntfmngr != null) {
ntfmngr.cancelAll();
}
Android 背景圖片的縮放實現
Android 背景圖片的縮放 ONE Goal ,ONE Passion !我們看到一些效果,控件中的背景圖片會慢慢變大,但是控件不會隨著圖片的放大而變大.效
(Android review)SharePreferences的使用
典型應用場合: 進入某一界面以後,顯示默認值(其實這個也可以通過直接在布局文件中指定) 基本點: 1)SharePreferences所生成的
安卓Andriod使用入門(十一)【下拉刷新】
MainActivity.java代碼:package siso.refreshablev;import android.app.Activity;import and
[搭建環境]React Native初嘗Mark筆記(Mac版+Android)
一、先在中文官網官網地址找到教案。二、Homebrew裝上(mac版本直接輸入下面的命令)。/usr/bin/ruby -e "$(curl -fsSL htt