小编Twi*_*kle的帖子

在通知中播放/暂停按钮图像,Android

我已经实现了音乐播放器,在播放流音频时会触发自定义通知.

一切正常,我可以使用通知中的按钮播放/暂停音频.唯一的问题是图像按钮:单击按钮无法更改图像以指示播放/暂停.

在RemoteReceiver中使用remoteViews.setImageViewResource()不起作用.控件是使用BroadcastReceiver完成的,这是从玩家活动中触发通知的代码:

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

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

      RemoteViews notificationView = new RemoteViews(getPackageName(), R.layout.notification_view);
      notificationView.setImageViewResource(R.id.button1, R.drawable.pause);
      notificationView.setTextViewText(R.id.textView1, songName);

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

      notification.contentView = notificationView;
      notification.contentIntent = pendingNotificationIntent;     

      Intent switchIntent = new Intent("com.example.test.ACTION_PLAY");
      PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0, switchIntent, PendingIntent.FLAG_UPDATE_CURRENT);

      notificationView.setOnClickPendingIntent(R.id.play_pause, pendingSwitchIntent);
      notificationManager.notify(1, notification); …
Run Code Online (Sandbox Code Playgroud)

notifications android media-player android-remoteview

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

没有Google+按钮的trySilentAuthentication

我正在iOS中实施Google+登录,我使用此代码并且工作正常

signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
//signIn.shouldFetchGoogleUserEmail = YES;
signIn.shouldFetchGooglePlusUser = YES;
signIn.clientID = kClientId;
signIn.scopes = [NSArray arrayWithObjects:kGTLAuthScopePlusLogin,nil];
signIn.actions = [NSArray arrayWithObjects:@"http://schemas.google.com/ListenActivity",nil];
[signIn authenticate];
Run Code Online (Sandbox Code Playgroud)

我想使用[signIn trySilentAuthentication]方法,每次用户登录时都不会离开,但如果不使用google +按钮GPPSignInButton则无法使用

那么,使用此代码而不是上面的代码有什么问题

  signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
//signIn.shouldFetchGoogleUserEmail = YES;
signIn.shouldFetchGooglePlusUser = YES;
signIn.clientID = kClientId;
signIn.scopes = [NSArray arrayWithObjects:kGTLAuthScopePlusLogin,nil];
signIn.actions = [NSArray arrayWithObjects:@"http://schemas.google.com/ListenActivity",nil];
[signIn trySilentAuthentication];
Run Code Online (Sandbox Code Playgroud)

是否可以在didSelectRowAtIndexPath中使用trySilentAuthentication?提前致谢

ios google-plus

2
推荐指数
1
解决办法
1841
查看次数

Laravel 中的两个表和 orderBy 日期查询

我有两个表,每个表用于其 Eloquent 。我想从他们每个人那里获得特定领域的结果(使用where子句)

然后我想组合两个结果数组并按创建日期归档对它们进行排序

我怎样才能在 laravel5 中实现这一目标?我尝试利用关系但无法使其发挥作用

这个例子分别是两个数组

 $football = Football::where('playerId','=',$id)->get()->toArray();

  $tennis= Tennis::where('playerId','=',$id)->get()->toArray(); 
Run Code Online (Sandbox Code Playgroud)

提前致谢

php eloquent laravel-5

0
推荐指数
1
解决办法
2166
查看次数