background image

Intent intent =

new

Intent();

intent.setAction(Intent.

ACTION_CALL

);

intent.setData(Uri.parse(

"tel:0123456789"

));

PendingIntent pIntent = PendingIntent.getActivity(

this

, 0,

intent, 0);

/**

* 参数一:上下文对象
* 参数二:通知标题
* 参数三:通知内容
* 参数四:PendingIntent对象
* */

String contentTitle =

"通知标题"

;

String contentText =

"通知内容"

;

//API10之后不建议使用该方法

notification.setLatestEventInfo(this,contentTitle,

contentText, pIntent);

notiManager.notify(0,notification);

}

b)

创建自定义状态栏通知
i.

布局文件

res/layout/custom_notification.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp" >
<ImageView

android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp" />

<TextView

android:id="@+id/title"
android:layout_width="wrap_content"

android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
style="@style/NotificationTitle" />

<TextView

android:id="@+id/text"
android:layout_width="wrap_content"