小编Dha*_*adi的帖子

通知中的音乐播放器控制

如何在android中设置播放/暂停,下一个和上一个按钮的通知.

我是Android的新手,也是堆栈溢出的新手.所以请耐心等待.

在此输入图像描述

我开始播放歌曲时设置通知,如下所示:

`

@SuppressLint("NewApi")
public void setNotification(String songName){
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager notificationManager = (NotificationManager) getSystemService(ns);


    @SuppressWarnings("deprecation")
    Notification notification = new Notification(R.drawable.god_img, null, System.currentTimeMillis());

    RemoteViews notificationView = new RemoteViews(getPackageName(), R.layout.notification_mediacontroller);

    //the intent that is started when the notification is clicked (works)
    Intent notificationIntent = new Intent(this, AudioBookListActivity.class);
    PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.contentView = notificationView;
    notification.contentIntent = pendingNotificationIntent;
    notification.flags |= Notification.FLAG_NO_CLEAR;

    //this is the intent that is supposed to be called when the button is clicked …
Run Code Online (Sandbox Code Playgroud)

android android-notifications android-mediaplayer android-broadcast

28
推荐指数
1
解决办法
3万
查看次数

如何在我的应用程序中获取组织工作档案的电话记录历史记录(发布为私人应用程序)

在这里,我试图在我的应用程序中使用已发布的apk(在Play商店中发布为公共应用程序)获取最后一次调用日志历史记录.现在我已经将我的应用程序作为一个组织的私有应用程序发布了我无法在我的私有应用程序中获取呼叫日志历史记录,

要获取通话记录历史记录,我已经开发了如下代码:

  public class CallLogListener extends BroadcastReceiver {

  private String tag = "CallLogListener";
  History h;
  Call call;

  /**
   * This method is called when BroadcastReceiver receive some action from another app
   *
   * @param mContext Context which is received by BroadcastReceiver
   * @param i        Intent which is received by BroadcastReceiver
   */
  @Override
  public void onReceive(Context mContext, Intent i) {
      // TODO Auto-generated method stub
      try {
          h = new History(new Handler(), mContext, "0");
          mContext.getContentResolver().registerContentObserver(CallLog.Calls.CONTENT_URI, true, h); …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver contentobserver android-broadcastreceiver

5
推荐指数
1
解决办法
308
查看次数