Code example for RemoteControlClient

Methods: setPlaybackState, setTransportControlFlags

0
		// build the PendingIntent for the remote control client 
		Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
		mediaButtonIntent.setComponent(myEventReceiver);
		PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
		// create and register the remote control client 
		myRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
		myAudioManager.registerRemoteControlClient(myRemoteControlClient);
 
		myRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
		myRemoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP);
		 
		dialog = ProgressDialog.show(this, null, "曲を探しています...", true, false);
		final ContentResolver cr = this.getContentResolver();
		new Thread(new Runnable() {
			private String getWhereClause() {
				StringBuilder s = new StringBuilder();
				 
				s.append(MediaStore.Files.FileColumns.MEDIA_TYPE).append("=").append(MediaStore.Files.FileColumns.MEDIA_TYPE_NONE);
				s.append(" AND (");
				s.append("LOWER(").append(MediaStore.Files.FileColumns.DATA).append(") LIKE '%.s98'");
				s.append("OR LOWER(").append(MediaStore.Files.FileColumns.DATA).append(") LIKE '%.m'");