Example usage for android.os RemoteException printStackTrace

List of usage examples for android.os RemoteException printStackTrace

Introduction

In this page you can find the example usage for android.os RemoteException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.nbplus.iotapp.service.IoTService.java

private void sendNotificationToApplication(Message message) {
    Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get();
    if (clientMessenger != null) {
        if (clientMessenger != null) {
            try {
                clientMessenger.send(message);
            } catch (RemoteException e) {
                e.printStackTrace();
            }/*  ww w .  j  av a 2 s .  c  o  m*/
        }
    }
}

From source file:com.nbplus.iotapp.service.IoTService.java

/**
 * ??  Request?   ./*w ww  .j  av a 2s  .  com*/
 * ? Async ? ? ? ? ? ? ?  ??   .
 *
 * @param clientMessenger
 * @param msgId
 * @param command
 * @param result
 */
private void sendResultToApplication(Messenger clientMessenger, String msgId, String deviceId, int command,
        IoTResultCodes result) {
    if (clientMessenger != null) {
        Message response = new Message();
        response.what = IoTServiceCommand.COMMAND_RESPONSE;

        // ?? Bundle ? request command (int) result code (serializable)  ?.
        Bundle b = new Bundle();
        b.putString(IoTServiceCommand.KEY_MSGID, msgId);
        b.putInt(IoTServiceCommand.KEY_CMD, command);
        b.putString(IoTServiceCommand.KEY_DEVICE_UUID, deviceId);
        b.putSerializable(IoTServiceCommand.KEY_RESULT, result);
        response.setData(b);

        try {
            clientMessenger.send(response);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.sentaroh.android.TaskAutomation.ActivityTaskStatus.java

private void showMainDialog(String action) {

    // common ??//  ww w  .j a  va  2s  .  co  m
    mainDialog = new Dialog(context);
    mainDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mainDialog.setContentView(R.layout.task_status_dlg);

    if (util.isKeyguardEffective()) {
        Window win = mainDialog.getWindow();
        win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                //            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    }
    ;

    TextView title = (TextView) mainDialog.findViewById(R.id.task_status_dlg_title);
    title.setText(getString(R.string.msgs_status_dialog_title));
    setSchedulerStatus();
    historyListView = (ListView) mainDialog.findViewById(R.id.task_status_dlg_history_listview);
    statusListView = (ListView) mainDialog.findViewById(R.id.task_status_dlg_status_listview);

    historyAdapter = new AdapterTaskStatusHistoryList(this, R.layout.task_history_list_item,
            getTaskHistoryList());
    historyListView.setAdapter(historyAdapter);
    historyListView.setSelection(historyAdapter.getCount() - 1);
    historyListView.setEnabled(true);
    historyListView.setSelected(true);
    setTaskListLongClickListener();

    statusAdapter = new AdapterTaskStatusActiveList(this, R.layout.task_status_list_item, getActiveTaskList(1));
    statusListView.setAdapter(statusAdapter);
    statusListView.setSelection(statusAdapter.getCount() - 1);
    statusListView.setEnabled(true);
    statusListView.setSelected(true);

    setCancelBtnListener();

    final Button btnStatus = (Button) mainDialog.findViewById(R.id.task_status_dlg_status_btn);
    final Button btnHistory = (Button) mainDialog.findViewById(R.id.task_status_dlg_history_btn);

    final CheckBox cb_enable_scheduler = (CheckBox) mainDialog
            .findViewById(R.id.task_status_dlg_status_enable_scheduler);

    final Button btnLog = (Button) mainDialog.findViewById(R.id.task_status_dlg_log_btn);
    final Button btnClose = (Button) mainDialog.findViewById(R.id.task_status_dlg_close_btn);

    CommonDialog.setDlgBoxSizeLimit(mainDialog, true);
    //      mainDialog.setOnKeyListener(new DialogOnKeyListener(context));

    cb_enable_scheduler.setChecked(envParms.settingEnableScheduler);
    cb_enable_scheduler.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        private boolean ignoreEvent = false;

        @Override
        public void onCheckedChanged(CompoundButton arg0, final boolean isChecked) {
            if (ignoreEvent) {
                ignoreEvent = false;
                return;
            }
            NotifyEvent ntfy = new NotifyEvent(null);
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    envParms.setSettingEnableScheduler(context, isChecked);
                    try {
                        svcServer.aidlCancelAllActiveTask();
                        svcServer.aidlResetScheduler();
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                    setSchedulerStatus();
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                    ignoreEvent = true;
                    cb_enable_scheduler.setChecked(!isChecked);
                }
            });
            String msg = "";
            if (!isChecked)
                msg = context.getString(R.string.msgs_status_dialog_enable_scheduler_confirm_msg_disable);
            else
                msg = context.getString(R.string.msgs_status_dialog_enable_scheduler_confirm_msg_enable);
            CommonDialog cd = new CommonDialog(context, getSupportFragmentManager());
            cd.showCommonDialog(true, "W", "", msg, ntfy);
        }
    });

    btnStatus.setBackgroundResource(R.drawable.button_back_ground_color_selector);
    btnHistory.setBackgroundResource(R.drawable.button_back_ground_color_selector);

    if (action.equals("History")) {
        statusListView.setVisibility(ListView.GONE);
        historyListView.setVisibility(ListView.VISIBLE);
        btnStatus.setTextColor(Color.DKGRAY);
        btnHistory.setTextColor(Color.GREEN);
        btnHistory.setClickable(false);
    } else {
        statusListView.setVisibility(ListView.VISIBLE);
        historyListView.setVisibility(ListView.GONE);
        btnStatus.setTextColor(Color.GREEN);
        btnHistory.setTextColor(Color.DKGRAY);
        btnStatus.setClickable(false);
    }

    btnStatus.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            statusListView.setVisibility(ListView.VISIBLE);
            historyListView.setVisibility(ListView.GONE);
            btnStatus.setTextColor(Color.GREEN);
            btnHistory.setTextColor(Color.DKGRAY);
            btnStatus.setClickable(false);
            btnHistory.setClickable(true);
            setSchedulerStatus();
        }
    });

    btnHistory.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            statusListView.setVisibility(ListView.GONE);
            historyListView.setVisibility(ListView.VISIBLE);
            btnStatus.setTextColor(Color.DKGRAY);
            btnHistory.setTextColor(Color.GREEN);
            btnStatus.setClickable(true);
            btnHistory.setClickable(false);
            setSchedulerStatus();
        }
    });

    if (util.isLogFileExists())
        btnLog.setEnabled(true);
    else
        btnLog.setEnabled(false);
    btnLog.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            util.resetLogReceiver();
            Intent intent = new Intent();
            intent = new Intent(android.content.Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + util.getLogFilePath()), "text/plain");
            startActivity(intent);
            setSchedulerStatus();
        }
    });

    // Close?
    btnClose.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mainDialog.dismiss();
            //            commonDlg.setFixedOrientation(false);
        }
    });
    mainDialog.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface arg0) {
            finish();
        }
    });
    // Cancel?
    mainDialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnClose.performClick();
        }
    });
    //      commonDlg.setFixedOrientation(true);
    mainDialog.setCancelable(true);
    mainDialog.show();

}

From source file:com.nbplus.iotapp.service.IoTService.java

/**
 *  ??  ? ? .//from   w w w.  j a  va 2 s .  c  o m
 */
private void sendServiceStatusNotification() {
    if (PackageUtils.isActivePackage(this, getApplicationContext().getPackageName() + ":remote")) {
        Log.d(TAG, "Remote process(RealtimeBroadcast..) is running...");
        return;
    }
    Messenger clientMessenger = (mRegisteredAppMessenger == null) ? null : mRegisteredAppMessenger.get();
    if (clientMessenger != null) {
        Message response = new Message();
        response.what = IoTServiceCommand.SERVICE_STATUS_NOTIFICATION;

        // ?? Bundle ? request command (int) result code (serializable)  ?.
        Bundle b = new Bundle();
        b.putString(IoTServiceCommand.KEY_MSGID,
                /*this.getApplicationContext().*/getPackageName() + "_" + System.currentTimeMillis());
        b.putSerializable(IoTServiceCommand.KEY_SERVICE_STATUS, mServiceStatus);
        b.putSerializable(IoTServiceCommand.KEY_SERVICE_STATUS_CODE, mErrorCodes);
        response.setData(b);

        try {
            clientMessenger.send(response);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.evolup.test.IAPTest01.util.IabHelper.java

/**
 * Starts the setup process. This will start up the setup process asynchronously.
 * You will be notified through the listener when the setup process is complete.
 * This method is safe to call from a UI thread.
 *
 * @param listener The listener to notify when the setup process is complete.
 *///from   w ww.ja  va  2s. c  om
public void startSetup(final OnIabSetupFinishedListener listener) {
    // If already set up, can't do it again.
    if (mSetupDone)
        throw new IllegalStateException("IAB helper is already set up.");

    // Connection to IAB service
    logDebug("Starting in-app billing setup.");
    mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            logDebug("Billing service disconnected.");
            mService = null;
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            logDebug("Billing service connected.");
            mService = IInAppBillingService.Stub.asInterface(service);
            String packageName = mContext.getPackageName();
            try {
                logDebug("Checking for in-app billing 3 support.");
                int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP);
                if (response != BILLING_RESPONSE_RESULT_OK) {
                    if (listener != null)
                        listener.onIabSetupFinished(
                                new IabResult(response, "Error checking for billing v3 support."));
                    return;
                }
                logDebug("In-app billing version 3 supported for " + packageName);
                mSetupDone = true;
            } catch (RemoteException e) {
                if (listener != null) {
                    listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION,
                            "RemoteException while setting up in-app billing."));
                }
                e.printStackTrace();
            }

            if (listener != null) {
                listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful."));
            }
        }
    };
    mContext.bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn,
            Context.BIND_AUTO_CREATE);
}

From source file:ac.robinson.bettertogether.hotspot.HotspotManagerService.java

private void sendSystemMessageToAllLocalClients(int type, String data) {
    for (int i = mClients.size() - 1; i >= 0; i--) {
        try {//from w  ww.jav  a2 s  . c  o  m
            Messenger client = mClients.get(i);
            Message message = Message.obtain(null, type);
            message.replyTo = mMessenger;
            if (data != null) {
                Bundle bundle = new Bundle(1);
                bundle.putString(PluginIntent.KEY_SERVICE_MESSAGE, data);
                message.setData(bundle);
            }
            client.send(message);
        } catch (RemoteException e) {
            e.printStackTrace();
            mClients.remove(i); // client is dead - ok to remove here as we're reversing through the list
        }
    }
}

From source file:org.cirrus.mobi.pegel.util.IabHelper.java

/**
 * Starts the setup process. This will start up the setup process asynchronously.
 * You will be notified through the listener when the setup process is complete.
 * This method is safe to call from a UI thread.
 *
 * @param listener The listener to notify when the setup process is complete.
 *///from  w  w  w .  j ava  2 s.  c  om
public void startSetup(final OnIabSetupFinishedListener listener) {
    // If already set up, can't do it again.
    if (mSetupDone)
        throw new IllegalStateException("IAB helper is already set up.");

    // Connection to IAB service
    logDebug("Starting in-app billing setup.");
    mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            logDebug("Billing service disconnected.");
            mService = null;
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            logDebug("Billing service connected.");
            mService = IInAppBillingService.Stub.asInterface(service);
            String packageName = mContext.getPackageName();
            try {
                logDebug("Checking for in-app billing 3 support.");
                int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP);
                if (response != BILLING_RESPONSE_RESULT_OK) {
                    if (listener != null)
                        listener.onIabSetupFinished(
                                new IabResult(response, "Error checking for billing v3 support."));
                    return;
                }
                logDebug("In-app billing version 3 supported for " + packageName);
                mSetupDone = true;
            } catch (RemoteException e) {
                if (listener != null) {
                    listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION,
                            "RemoteException while setting up in-app billing."));
                }
                e.printStackTrace();
            }

            if (listener != null) {
                listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful."));
            }
        }
    };
    Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");

    intent.setPackage("com.android.vending");
    mContext.bindService(intent, mServiceConn, Context.BIND_AUTO_CREATE);
}

From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java

private void createMediaSession() {
    if (mSession == null) {
        mSession = new MediaSessionCompat(getActivity(), "LeanbackSampleApp");
        mSession.setCallback(new MediaSessionCallback());
        mSession.setFlags(FLAG_HANDLES_MEDIA_BUTTONS | FLAG_HANDLES_TRANSPORT_CONTROLS);
        mSession.setActive(true);//www  .  j av  a  2  s . com

        // Set the Activity's MediaController used to invoke transport controls / adjust volume.
        try {
            ((FragmentActivity) getActivity()).setSupportMediaController(
                    new MediaControllerCompat(getActivity(), mSession.getSessionToken()));
            setPlaybackState(PlaybackState.STATE_NONE);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}

From source file:me.trashout.fragment.DashboardFragment.java

@Override
public void onDestroy() {
    super.onDestroy();
    // Unbind from the service
    if (mTrashHunterBound) {
        try {/*from w  w  w.j  ava  2  s  .co m*/
            mService.removeOnTrashHunterChangeListener(onTrashHunterChangeListener);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        getActivity().unbindService(svcConn);
        mTrashHunterBound = false;
    }
}

From source file:ac.robinson.bettertogether.hotspot.HotspotManagerService.java

@SuppressFBWarnings("ANDROID_BROADCAST")
private void sendBroadcastMessageToAllLocalClients(BroadcastMessage msg) {
    for (int i = mClients.size() - 1; i >= 0; i--) {
        try {/* www.  j  av a  2 s  .  co m*/
            // local directly connected activities (i.e., ours)
            Messenger client = mClients.get(i);
            Message message = Message.obtain(null, MSG_BROADCAST);
            message.replyTo = mMessenger;
            Bundle bundle = new Bundle(1);
            bundle.putSerializable(PluginIntent.KEY_BROADCAST_MESSAGE, msg);
            message.setData(bundle);
            client.send(message);

            // local unconnected activities (i.e., plugins)
            Log.d(TAG,
                    "Sending broadcast message to all local clients with package "
                            + mConnectionOptions.mPluginPackage + " - type: " + msg.getType() + ", message: "
                            + msg.getMessage());
            Intent broadcastIntent = new Intent(PluginIntent.ACTION_MESSAGE_RECEIVED);
            broadcastIntent.setClassName(mConnectionOptions.mPluginPackage, PluginIntent.MESSAGE_RECEIVER);
            // TODO: source is only necessary for internal plugins - remove later?
            broadcastIntent.putExtra(PluginIntent.EXTRA_SOURCE, HotspotManagerService.this.getPackageName());
            broadcastIntent.putExtra(PluginIntent.KEY_BROADCAST_MESSAGE, msg);
            sendBroadcast(broadcastIntent);
        } catch (RemoteException e) {
            e.printStackTrace();
            mClients.remove(i); // client is dead - ok to remove here as we're reversing through the list
        }
    }
}