小编use*_*425的帖子

没有收到NotificationCompat.Builder的通知

我想生成一个通知栏,通过构建器方法显示进度,但我不知道我哪里出错了.如果有人能告诉我我哪里错了,请帮助我,我会感激.....

public class DownloadReceiver extends ResultReceiver{
    private final static String TAG = "DownloadReceiver"; 
    public Context context;
    public DownloadReceiver(Handler handler,Context context) {
        super(handler);
        this.context = context;
        Log.d(TAG,handler.getLooper().getThread().getName());
    }

    @Override
    protected void onReceiveResult(int resultCode, Bundle resultData) {
        super.onReceiveResult(resultCode, resultData);
        Log.d(TAG,"in download receiver");

        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
        Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notifyIntent, 0);

    if(resultCode == DownloadService.COMPLETED){
            Log.d(TAG,resultCode + "");
            Builder notificationBuilder = new NotificationCompat.Builder(context)
                                          .setProgress(100, 20, false)
                                          .addAction(R.drawable.ic_action_search, "title", pendingIntent)
                                          .setWhen(System.currentTimeMillis());
    //      notification.flags = Notification.FLAG_ONGOING_EVENT;
            // …
Run Code Online (Sandbox Code Playgroud)

android-notifications

4
推荐指数
1
解决办法
2495
查看次数

标签 统计

android-notifications ×1