결과화면
notiMgr.notify(0, notification); 오류 발생!!!
왜 오류가 나나 했더니 클래스 파일명이
중복되서 그러는 거였다..... ㅜㅜ
그러므로 클래스 파일명을 NotificationManagerActivity로 바꾸고 나서 해결.....
// NotificationManagerActivity.java
package com.example.hellow;
import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.*; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button;
public class NotificationManagerActivity extends Activity implements View.OnClickListener { NotificationManager notiMgr; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.notification); notiMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Button button = (Button)findViewById(R.id.button); button.setOnClickListener(this); } public void onClick(View v){ Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:0101234567")); PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new Notification(R.drawable.ic_launcher, "전화", System.currentTimeMillis()); notification.setLatestEventInfo(NotificationManagerActivity.this, "전화걸기", "전화 걸 시간입니다.", pendingIntent); notification.flags = Notification.FLAG_AUTO_CANCEL; notiMgr.notify(0, notification); }
}
|
// notification.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >
<Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="통지하기" />
</LinearLayout> |