download: http://www.mediafire.com/download/1nis9ose1xs13u2/NotificationCustom.zip
package com.mirtech.mirtube;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RemoteViews;
public class SplashActivity extends Activity {
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = SplashActivity.this;
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.splash);
remoteViews.setTextViewText(R.id.textView1, "ssssssss");
// When we click the widget, we want to open our main activity.
Intent defineIntent2 = new Intent(context, MyBroadcastReceiver.class);
PendingIntent pendingIntent2 = PendingIntent.getBroadcast(context,
0 /* no requestCode */, defineIntent2, 0 /* no flags */);
remoteViews.setOnClickPendingIntent(R.id.button1, pendingIntent2);
Notification.Builder mBuilder = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher).setContent(remoteViews);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(100, mBuilder.build());
}
}
package com.mirtech.mirtube;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RemoteViews;
public class SplashActivity extends Activity {
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = SplashActivity.this;
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.splash);
remoteViews.setTextViewText(R.id.textView1, "ssssssss");
// When we click the widget, we want to open our main activity.
Intent defineIntent2 = new Intent(context, MyBroadcastReceiver.class);
PendingIntent pendingIntent2 = PendingIntent.getBroadcast(context,
0 /* no requestCode */, defineIntent2, 0 /* no flags */);
remoteViews.setOnClickPendingIntent(R.id.button1, pendingIntent2);
Notification.Builder mBuilder = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher).setContent(remoteViews);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(100, mBuilder.build());
}
}
package com.mirtech.mirtube;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context _context, Intent _intent) {
Log.e("-----onReceive", " ");
// if (_intent.getAction().equals("hi")) {
// // TODO Broadcast a notification
//
// }
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mirtech.mirtube"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.mirtech.mirtube.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="MyBroadcastReceiver" >
<intent-filter>
<action android:name="hi" />
</intent-filter>
</receiver>
</application>
</manifest>
No comments:
Post a Comment