下面列出了android.os.RemoteException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Set the PBSServiceConnection object.
* This will create a new Adapter.
*/
public void registerPBServiceConnection(PlaybackServiceConnection playbackServiceConnection) {
if(playbackServiceConnection == null) {
return;
}
mPlaybackServiceConnection = playbackServiceConnection;
mCurrentPlaylistAdapter = new CurrentPlaylistAdapter(mContext, mPlaybackServiceConnection);
mCurrentPlaylistAdapter.hideArtwork(mHideArtwork);
mListView.setAdapter(mCurrentPlaylistAdapter);
mListView.setOnScrollListener(new ScrollSpeedListener(mCurrentPlaylistAdapter));
// set the selection to the current track, so the list view will positioned appropriately
try {
mListView.setSelection(mPlaybackServiceConnection.getPBS().getCurrentIndex());
} catch (RemoteException e) {
e.printStackTrace();
}
}
/**
* Functions identically to android.media.MediaPlayer.isPlaying()
* @return True if the track is playing
*/
@Override
public boolean isPlaying() {
if (pmInterface == null) {
if (!ConnectPlayMediaService()) {
ServiceBackedMediaPlayer.this.error(MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
}
}
if (pmInterface != null) {
try {
return pmInterface.isPlaying(ServiceBackedMediaPlayer.this.sessionId);
} catch (RemoteException e) {
e.printStackTrace();
ServiceBackedMediaPlayer.this.error(MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
}
}
return false;
}
/**
* 发送消息到注册界面
*
* @param msgWhat
* @param msgObj
*/
private void sendMsg2Register(int msgWhat, String msgObj) {
if (mMessenger != null) {
Message msg = Message.obtain();
msg.what = msgWhat;
msg.obj = msgObj;
try {
mMessenger.send(msg);
} catch (RemoteException e) {
e.printStackTrace();
} finally {
stopSelf();
}
}
}
public void send(View view){
//通过Messenger发消息
Message msgToService = Message.obtain();
msgToService.what=200;
//带上参数
// msgToService.obj = "自古真情留不住"; 不行,要序列化
Bundle bundle = new Bundle();
bundle.putString("key","自古真情留不住");
msgToService.setData(bundle);
//Message有个变量,指定谁来接收返回的消息
msgToService.replyTo = messengerClient;
try {
messengerService.send(msgToService);
} catch (RemoteException e) {
e.printStackTrace();
}
}
private void handleShowMore() {
if (mDialog.visible()) {
mDialog.hide();
} else {
Song s = null;
try {
s = control.currentSong();
} catch (RemoteException e) {
e.printStackTrace();
}
SongInfo info = mediaManager.getSongInfo(activity, s);
String title = activity.getString(R.string.song) + ": " + info.getTitle();
mDialog.setTitle(title);
mDialog.show();
}
}
public boolean answerCallNative() {
boolean ret = false;
if (mBinder != null) {
try {
if (mBinder.acceptCall()) {
LogUtil.d(TAG, "Accept call in success");
ret = true;
} else {
LogUtil.d(TAG, "Accept call in failure");
ret = false;
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
return ret;
}
@Override
public void onClick(View v) {
try {
if (v == mCloseCall) {
getXmppBinder().closeCall();
stopRingtone();
CallActivity.call_state = UA_STATE_IDLE;
finish();
} else if (v == mAcceptCall) {
getXmppBinder().acceptCall();
stopRingtone();
CallActivity.call_state = UA_STATE_INCALL;
mAcceptCall.setVisibility(View.GONE);
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
/**
* Ask InstrumentationService to send its configuration.
*/
public void askForConfiguration() {
if (!mBound) {
Log.i(TAG, "mBound is null, sendEvent failed");
return;
}
Message msg = Message.obtain(null, InstrumentationService.GetConfiguration);
msg.replyTo = mMessenger;
try {
Log.i(TAG, "Asking configuration if instrumentation service");
mService.send(msg);
} catch (RemoteException e) {
e.printStackTrace();
}
}
/**
* Functions identically to android.media.MediaPlayer.isLooping()
* @return True if the track is looping
*/
@Override
public boolean isLooping() {
Log.d(SBMP_TAG, "isLooping() 382");
if (pmInterface == null) {
if (!ConnectPlayMediaService()) {
ServiceBackedMediaPlayer.this.error(MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
}
}
try {
return pmInterface.isLooping(ServiceBackedMediaPlayer.this.sessionId);
} catch (RemoteException e) {
e.printStackTrace();
ServiceBackedMediaPlayer.this.error(MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
}
return false;
}
@Override
public void run() {
try {
mService.readRemoteRSSI(mDevice.getAddress());
} catch (RemoteException rex) {
rex.printStackTrace();
}
}
/**
* Saves the current state as a bookmark. This just calls the PBS and asks him to save the state.
*
* @param bookmarkTitle Name of the bookmark to store.
*/
public void createBookmark(String bookmarkTitle) {
// call pbs and create bookmark with the given title for the current state
try {
mServiceConnection.getPBS().createBookmark(bookmarkTitle);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Save a single status update.
* @param statusUpdate The status update to be stored.
*/
public void persist(StatusUpdate statusUpdate) {
ContentValues values = new ContentValues();
try {
put(values, statusUpdate);
provider.insert(StatusUpdates.CONTENT_URI, values);
} catch (RemoteException e) {
e.printStackTrace();
}
}
private void callConnectedMethodLocked(IServiceConnection conn, ComponentName cn, IBinder b) {
try {
conn.connected(cn, b);
} catch (RemoteException e) {
if (BuildConfig.DEBUG) {
e.printStackTrace();
}
}
}
public void publishService(IBinder token, Intent intent, IBinder service) {
try {
getService().publishService(token, intent, service, VUserHandle.myUserId());
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.list_bottom_nav_container:
ActivityManager.getInstance().startPlayActivity(activity);
break;
case R.id.list_play: {
boolean play = mPlay.isChecked();
try {
if (play) {
mControl.resume();
} else mControl.pause();
} catch (RemoteException e) {
e.printStackTrace();
}
break;
}
case R.id.list_list:
if (listViewsController.visible()) {
listViewsController.hide();
} else {
listViewsController.show();
}
break;
default:
break;
}
}
public void exit(Activity ctx,SdkExitCallBack exitCallBack){
IBinder binder = RePlugin.fetchBinder("funcellplugin", "sdkImpl");
if(binder == null){
return;
}
IInteractiveService service = IInteractiveService.Stub.asInterface(binder);
try {
service.Exit(exitCallBack);
} catch (RemoteException e) {
e.printStackTrace();
}
}
private void playPause(){
Log.d(TAG, "Play/Pause clicked...");
Message msg = Message.obtain(null, MusicPlaybackService.MSG_PLAYPAUSE);
try {
Log.i(TAG, "Sending a request to start playing!");
mService.send(msg);
} catch (RemoteException e) {
e.printStackTrace();
}
}
public void onServiceConnected(ComponentName componentName, IBinder service) {
logger.debug("onServiceConnected {}/{}", componentName.getPackageName(), componentName.getShortClassName());
io.joynr.android.messaging.binder.JoynrBinder remoteServiceClient = io.joynr.android.messaging.binder.JoynrBinder.Stub.asInterface(
service);
try {
remoteServiceClient.transmit(data);
} catch (RemoteException error) {
error.printStackTrace();
failureAction.execute(error);
}
context.unbindService(this);
successAction.execute();
}
/**
* 启动蓝牙Service 端,此方法用于Service 端
*/
public void startService(){
if (mProxyService != null){
try {
mProxyService.startService();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
private void updateState(boolean resetConnectionTest) {
if (mServiceBoundContext.bgService != null) {
try {
int state = mServiceBoundContext.bgService.getState();
switch (state) {
case Constants.State.CONNECTING:
fab.setBackgroundTintList(greyTint);
serviceStarted = false;
fab.setImageResource(R.drawable.ic_start_busy);
preferences.setEnabled(false);
fabProgressCircle.show();
stat.setVisibility(View.GONE);
break;
case Constants.State.CONNECTED:
fab.setBackgroundTintList(greenTint);
serviceStarted = true;
fab.setImageResource(R.drawable.ic_start_connected);
preferences.setEnabled(false);
fabProgressCircle.postDelayed(new Runnable() {
@Override
public void run() {
hideCircle();
}
}, 100);
stat.setVisibility(View.VISIBLE);
if (resetConnectionTest) {
if (ShadowsocksApplication.app.isNatEnabled()) {
connectionTestText.setVisibility(View.GONE);
} else {
connectionTestText.setVisibility(View.VISIBLE);
connectionTestText.setText(getString(R.string.connection_test_pending));
}
}
break;
case Constants.State.STOPPING:
fab.setBackgroundTintList(greyTint);
serviceStarted = false;
fab.setImageResource(R.drawable.ic_start_busy);
preferences.setEnabled(false);
fabProgressCircle.show();
stat.setVisibility(View.GONE);
break;
default:
fab.setBackgroundTintList(greyTint);
serviceStarted = false;
fab.setImageResource(R.drawable.ic_start_idle);
preferences.setEnabled(true);
fabProgressCircle.postDelayed(new Runnable() {
@Override
public void run() {
hideCircle();
}
}, 100);
stat.setVisibility(View.GONE);
break;
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
}