編輯:關於Android編程
package com.example.noti;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
public class MainActivity extends
Activity {
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//NotificationManager獲取NOTIFICATION_SERVICE
final NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
findViewById(R.id.button1)
.setOnClickListener(
new OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(
View v) {
// TODO Auto-generated method stub
//創建一個Notification
Notification notification = new Notification();
//狀態欄顯示信息
notification.icon = R.drawable.ic_launcher;
notification.tickerText = "This is test notification55555";
notification.vibrate = new long[] {
0,
100,
200,
300 };
//系統鈴聲
String ringname = RingtoneManager
.getActualDefaultRingtoneUri(
MainActivity.this,
RingtoneManager.TYPE_RINGTONE)
.toString();
notification.sound = Uri
.parse(ringname);
//閃光燈
notification.ledOnMS=300;
notification.ledOffMS=1000;
//切換到另一個ACTIVITY
PendingIntent pendingIntent = PendingIntent
.getActivity(
MainActivity.this,
0,
new Intent(
MainActivity.this,
MainActivity.class),
0);
//信息
notification
.setLatestEventInfo(
MainActivity.this,
"NOTIFICATION",
"This is test notification",
pendingIntent);
notificationManager
.notify(0,
notification);
}
});
}
@Override
public boolean onCreateOptionsMenu(
Menu menu) {
getMenuInflater().inflate(
R.menu.activity_main,
menu);
return true;
}
}
(一)繪制最簡單的圓形ImageViewRoundedImageViewCircleImageView運行效果:實現代碼:自定義ImageView代碼:package c
一些復雜語言如泰語、緬甸語、印地語,經常會看到一些帶有虛線圈圈字符。這是一種正常的處理機制。對於那些不能單獨存在的字符,在顯示時額外添加虛線圈,以提供對於這
我在簡書上發布了我個人的第一篇技術文檔:RecyclerView系列之: RecyclerView系列之(1)為RecyclerView添加Header和Footer,也
一個人需要隱藏多少秘密才能巧妙地度過一生 — 倉央嘉措前言上次看到一款學習的 App,有這樣一個功能,在一個 TextView 中有一段英文,點擊英文單詞通過