編輯:關於Android編程
//Android發送多個notification ,PendingIntent的ID很重要。
public void addNotification(JSONArray args, CallbackContext callbackContext) throws JSONException {
//NOTIFICATION_ID = args.getInt(6);
NOTIFICATION_ID = (int)(Math.random()*10000);
try {
nm = (NotificationManager) cordova.getActivity().getSystemService(
Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(cx, cordova.getActivity().getClass());
intent.putExtra("clickAction", args.getString(4));
String clickActionParams = args.getJSONObject(5).toString();
intent.putExtra("clickActionParams", clickActionParams);
PendingIntent pIntent = PendingIntent.getActivity(cx, NOTIFICATION_ID, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
int version = android.os.Build.VERSION.SDK_INT;
Notification notify;
// 如果版本號大於15.即采用notification.builder方法,如果版本號小於15,即采用舊方法,避免類似盧峰手機的問題
if (version > 15) {
notify = new Notification.Builder(cx)
// 設置打開該通知,該通知自動消失
.setAutoCancel(true)
// 設置顯示在狀態欄的通知提示信息
.setTicker(args.getString(0))
// 設置通知的圖標
.setSmallIcon(R.drawable.icon)
// 設置通知內容的標題
.setContentTitle(args.getString(0))
// 設置通知內容
.setContentText(args.getString(1) + NOTIFICATION_ID)
.setWhen(System.currentTimeMillis())
// 設改通知將要啟動程序的Intent
.setContentIntent(pIntent).build();
} else {
notify = new Notification(R.drawable.icon, args.getString(0),
System.currentTimeMillis());
notify.setLatestEventInfo(cx, args.getString(0),
args.getString(1), pIntent);
}
// 發送通知
nm.notify(NOTIFICATION_ID, notify);
// 通知顯示X秒後自動清除
if (args.getBoolean(2)) {
disappearTime = args.getLong(3);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// TODO Auto-generated method stub
nm.cancel(NOTIFICATION_ID);
}
}, disappearTime);
}
} catch (JSONException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
Android通訊錄模糊查詢搜索(號碼,姓名,首字母簡拼,全拼),批量選取聯系人
Android通訊錄模糊查詢搜索(號碼,姓名,首字母簡拼,全拼),批量選取聯系人 公司最近的項目中遇到一個需求需要讀取通訊錄聯系人,並需要支持對聯系人的模糊查詢及批量選
android開發步步為營之32:玩轉Toast
Toast英文名為土司,在Android裡面這個類是用來彈出提示信息的,我想sdk作者是認為提示信息片長得就像一塊土司吧。這個理論就不多說什麼了,開始我們的實踐。 第一步
Android下的CMD命令之關機重啟及重啟recovery
Android剛興起的時候,著實讓一些小眾軟件火了一把,切水果,Tom貓,吹裙子就是其中的代表,當然還有實用性很強的關機重啟軟件,我們去百度上搜索一下。截圖:一.了解CM
Android特效之水波紋的實現
前言水波紋特效,想必大家或多或少見過,在我的印象中,大致有如下幾種: 支付寶 咻咻咻 式