package com.exam1ple.demo1;
import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.BigPictureStyle;
import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationCompat.InboxStyle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.RemoteViews;
import android.widget.Toast;
public class MainActivity extends Activity {
static final String STATUS_BAR_COVER_CLICK_ACTION = "com.fmy.fmy";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void MyClick01(View v) {
BroadcastReceiver onClickReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(STATUS_BAR_COVER_CLICK_ACTION)) {
System.out.println("---");
System.out.println("---");
System.out.println("---");
System.out.println("---");
System.out.println("---");
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(STATUS_BAR_COVER_CLICK_ACTION);
registerReceiver(onClickReceiver, filter);
Intent buttonIntent = new Intent(STATUS_BAR_COVER_CLICK_ACTION);
PendingIntent pendButtonIntent = PendingIntent.getBroadcast(this, 0, buttonIntent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentText("切换歌曲");
builder.setContentTitle("反正就是个标题");
builder.setSmallIcon(R.drawable.ic_launcher);
RemoteViews view = new RemoteViews(getPackageName(), R.layout.layout);
view.setOnClickPendingIntent(R.id.tv, pendButtonIntent);
builder.setContent(view);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(1, builder.build());
}
}