Example usage for android.os Message setData

List of usage examples for android.os Message setData

Introduction

In this page you can find the example usage for android.os Message setData.

Prototype

public void setData(Bundle data) 

Source Link

Document

Sets a Bundle of arbitrary data values.

Usage

From source file:push.dantech.com.personalpushnotifications.MyFirebaseMessagingService.java

/**
 * Called when message is received./*from  ww w.  j  a  v a  2s.c o m*/
 *
 * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
 */
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    System.out.println("From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        System.out.println("Message data payload: " + remoteMessage.getData());
        Message msg = new Message();
        Bundle data = new Bundle();
        data.putString("message", remoteMessage.getData().get("message"));
        msg.setData(data);
        handler.sendMessage(msg);
    }

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        System.out.println("Message Notification Body: " + remoteMessage.getNotification().getBody());
    }
}

From source file:com.tenkiv.tekdaqc.android.services.DiscoveryService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    // Extract the service instruction
    final String action = intent.getAction();

    // Build the message parameters
    Bundle extras = intent.getExtras();//  ww w  . j  ava2 s  .co  m
    if (extras == null)
        extras = new Bundle();
    extras.putString(TekCast.EXTRA_SERVICE_ACTION, action);

    // Run each command in the background thread.
    final Message msg = mServiceHandler.obtainMessage();
    msg.arg1 = startId;
    msg.setData(extras);
    mServiceHandler.sendMessage(msg);
    return START_NOT_STICKY;
}

From source file:com.softminds.matrixcalculator.OperationFragments.FunctionalFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == 1452) {
        if (((GlobalValues) getActivity().getApplication()).DonationKeyFound()) {
            try {
                final Function function = ((GlobalValues) getActivity().getApplication()).getFunction();
                Runnable runnable = new Runnable() {
                    @Override/*ww w.  j  a  v a 2 s .c  om*/
                    public void run() {
                        MatrixV2 m = function.ComputeFunction(SquareList.get(ClickPos));
                        Message message = new Message();
                        message.setData(m.getDataBundled());
                        myHandler.sendMessage(message);
                    }
                };
                Thread thread = new Thread(runnable);
                thread.start();
            } catch (NullPointerException e) {
                Log.d("Exception : ", "Function at Global Context is Null");
                e.printStackTrace();
            }
        } else {
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            builder.setCancelable(true);
            builder.setPositiveButton(R.string.Upgrade, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    final String ProPackage = "com.softminds.matrixcalculator.pro.key";
                    try {
                        Intent intent = new Intent(Intent.ACTION_VIEW,
                                Uri.parse("market://details?id=" + ProPackage));
                        startActivity(intent);
                        Toast.makeText(getContext(), R.string.OpeningPlay, Toast.LENGTH_SHORT).show();
                    } catch (ActivityNotFoundException e) { //if Play store is not installed
                        startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("https://play.google.com/store/apps/details?id=" + ProPackage)));
                    }
                    dialogInterface.dismiss();
                }
            });
            builder.setNegativeButton(R.string.Nope, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
            builder.setTitle(getString(R.string.Upgrade));
            builder.setMessage(R.string.UpgradeMess);
            builder.show();
        }
    }
}

From source file:com.nextgis.metroaccess.MetaDownloader.java

@Override
protected void onPostExecute(Void unused) {
    super.onPostExecute(unused);

    DismissDowloadDialog();/*from   ww w  .  ja  va  2 s. com*/

    if (msError != null) {
        if (moEventReceiver != null) {
            Bundle bundle = new Bundle();
            bundle.putBoolean(BUNDLE_ERRORMARK_KEY, true);
            bundle.putString(BUNDLE_MSG_KEY, msError);
            bundle.putInt(BUNDLE_EVENTSRC_KEY, 1);

            Message oMsg = new Message();
            oMsg.setData(bundle);
            moEventReceiver.sendMessage(oMsg);
        }
    }
}

From source file:com.nextgis.uikobserver.HttpSendData.java

@Override
protected void onPostExecute(Void unused) {
    super.onPostExecute(unused);
    if (mbShowProgress) {
        mDownloadDialog.dismiss();/*w w  w .j  a  va2s . c  o  m*/
    }
    if (mError != null) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("error", true);
        bundle.putString("err_msq", mError);
        bundle.putInt("src", mnType);

        Message msg = new Message();
        msg.setData(bundle);
        if (mEventReceiver != null) {
            mEventReceiver.sendMessage(msg);
        }
    } else {
        //Toast.makeText(FireReporter.this, "Source: " + Content, Toast.LENGTH_LONG).show();
    }
}

From source file:com.ongtonnesoup.permissions.PerMissions.java

/**
 * Callback received when user selects dialog option
 *
 * @param requestCode  Permissions request code
 * @param permissions  Permissions requested
 * @param grantResults Permissions granted
 *///  w w  w  . j  a  v a  2 s. co  m
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    if (requestCode == REQUEST_PERMISSIONS) {
        Message message = new Message();
        message.what = requestCode;
        message.setData(PerMissionsResultBundleHelper.makeBundle(permissions, grantResults));
        queue.sendMessage(message);
    } else {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}

From source file:ibp.plugin.nsd.NSDPlugin.java

private void sendByHandler(String type, String data) {
    if (null != mHandler) {
        Bundle messageBundle = new Bundle();
        messageBundle.putString("type", type);
        messageBundle.putString("msg", data);
        Message message = new Message();
        message.setData(messageBundle);
        mHandler.sendMessage(message);//from www  .j  av  a  2  s . c o m
    }
}

From source file:com.nextgis.firereporter.HttpGetter.java

@Override
protected void onPostExecute(Void unused) {
    super.onPostExecute(unused);
    DismissDowloadDialog();//from w w w. ja  v a  2 s .c o m
    if (mError != null) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(GetFiresService.ERROR, true);
        bundle.putString(GetFiresService.ERR_MSG, mError);
        bundle.putInt(GetFiresService.SOURCE, mnType);

        Message msg = new Message();
        msg.setData(bundle);

        if (mEventReceiver != null) {
            mEventReceiver.sendMessage(msg);
        }
    } else {
        //Toast.makeText(MainActivity.this, "Source: " + Content, Toast.LENGTH_LONG).show();
    }
}

From source file:com.softminds.matrixcalculator.OperationFragments.RankFragment.java

private void FindRank(final int pos) {
    Runnable runnable = new Runnable() {
        @Override//from w w  w .  j a  v  a2 s .c o  m
        public void run() {
            MatrixV2 mat = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos);
            double rank = mat.getRank();
            Message message = new Message();
            Bundle bundle = new Bundle();
            bundle.putDouble("CALCULATED_RANK", rank);
            message.setData(bundle);
            handler.sendMessage(message);
        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
}

From source file:com.nextgis.firereporter.ScanexHttpLogin.java

@Override
protected void onPostExecute(Void unused) {
    super.onPostExecute(unused);
    if (mbShowProgress) {
        mDownloadDialog.dismiss();/*from  ww w .j a va2s .  c om*/
    }
    if (mError != null) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(GetFiresService.ERROR, true);
        bundle.putString(GetFiresService.ERR_MSG, mError);
        bundle.putInt(GetFiresService.SOURCE, mnType);

        Message msg = new Message();
        msg.setData(bundle);
        if (mEventReceiver != null) {
            mEventReceiver.sendMessage(msg);
        }
    }
}