------------------------manifest------------------------
package
=
"kr.appsol.util.calc.formcalc.skin.whitesilver"
android:versionCode=
"3"
android:versionName=
"2.4"
>
<uses-sdk
android:minSdkVersion=
"3"
android:targetSdkVersion=
"17"
/>
<uses-permission android:name=
"android.permission.VIBRATE"
/>
<uses-permission android:name=
"android.permission.REPLACED_PACKAGES"
/>
<uses-permission android:name=
"android.permission.ADDED_PACKAGES"
/>
<application
android:allowBackup=
"true"
android:icon=
"@drawable/whitesilver_img_share_emblem"
android:label=
"@string/app_name"
android:theme=
"@style/AppTheme"
>
<service
android:name=
".NotificationService"
android:enabled=
"true"
/>
<receiver android:name=
".PackageReceiver"
>
<intent-filter>
<action android:name=
"android.intent.action.PACKAGE_ADDED"
/>
<action android:name=
"android.intent.action.PACKAGE_REPLACED"
/>
<data android:scheme=
"package"
/>
</intent-filter>
</receiver>
</application>
</manifest>
------------------------BroadcastReceiver------------------------
public
class
PackageReceiver
extends
BroadcastReceiver{
@Override
public
void
onReceive(Context context, Intent intent) {
Intent i =
new
Intent(context, NotificationService.
class
);
context.startService(i);
}
}
------------------------Service Class------------------------
public
class
NotificationService
extends
Service {
@Override
public
IBinder onBind(Intent intent) {
return
null
;
}
@SuppressWarnings
(
"deprecation"
)
@Override
public
void
onCreate(){
NotificationManager mNotificationManager = (NotificationManager)getSystemService( Context.NOTIFICATION_SERVICE);
int
icon = R.drawable.ic_launcher;
CharSequence tickerText =
"Hello"
;
long
when = System.currentTimeMillis();
Notification notification =
new
Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle =
"My notification"
;
CharSequence contentText =
"Hello World!"
;
Intent notificationIntent =
new
Intent(Intent.ACTION_VIEW, Uri.parse(
"www.google.com"
));
PendingIntent contentIntent = PendingIntent.getActivity(
this
,
0
, notificationIntent,
0
);
notification.setLatestEventInfo( context, contentTitle, contentText, contentIntent);
notification.defaults |= Notification.DEFAULT_VIBRATE;
mNotificationManager.notify(
7727
, notification);
}
@Override
public
void
onDestroy(){ }
}