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:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java

public void openMultiPopover(String[] parm) {
    Log.d("multi", "open multi pop");
    if (parm.length < 10) {
        return;//from  ww w .ja va  2s .co  m
    }
    Message msg = new Message();
    msg.obj = this;
    msg.what = MSG_FUNCTION_OPENMULTIPOPOVER;
    Bundle bd = new Bundle();
    bd.putStringArray(TAG_BUNDLE_PARAM, parm);
    msg.setData(bd);
    if (parm.length > 10) {
        //?11?
        long delay = 0l;
        try {
            JSONObject json = new JSONObject(parm[10]);
            JSONObject data = new JSONObject(json.getString(EBrwViewEntry.TAG_EXTRAINFO));
            if (data.has(EBrwViewEntry.TAG_DELAYTIME)) {
                delay = Long.valueOf(data.getString(EBrwViewEntry.TAG_DELAYTIME));
            }
        } catch (Exception e) {
        }
        mHandler.sendMessageDelayed(msg, delay);
    } else {
        mHandler.sendMessage(msg);
    }
}

From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java

public void publishChannelNotificationForJson(String[] params) {
    if (params == null || params.length < 2) {
        errorCallback(0, 0, "error params!");
        return;/*from w  w  w . ja v  a2s  .  c o m*/
    }
    Message msg = new Message();
    msg.obj = this;
    msg.what = MSG_PUBLISH_CHANNEL_NOTIFICATION_FOR_JSON;
    Bundle bd = new Bundle();
    bd.putStringArray(TAG_BUNDLE_PARAM, params);
    msg.setData(bd);
    mHandler.sendMessage(msg);
}

From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java

public void setSelectedPopOverInMultiWindow(String[] parm) {
    if (parm == null || parm.length < 2) {
        errorCallback(0, EUExCallback.F_E_UEXWINDOW_EVAL, "Illegal parameter");
        return;//from  w w w.  j  ava 2 s.  c om
    }
    Message msg = new Message();
    msg.obj = this;
    msg.what = MSG_FUNCTION_SETSELECTEDPOPOVERINMULTIWINDOW;
    Bundle bd = new Bundle();
    bd.putStringArray(TAG_BUNDLE_PARAM, parm);
    msg.setData(bd);
    mHandler.sendMessage(msg);
}

From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java

public void closeAboveWndByName(String[] parm) {
    String windowName = "";
    if (parm.length > 0 && !TextUtils.isEmpty(parm[0])) {
        windowName = parm[0];//from ww w .j  a  v a  2s  . c  o  m
    }
    Message msg = mHandler.obtainMessage();
    msg.what = MSG_FUNCTION_CLOSE_ABOVE_WND_BY_NAME;
    msg.obj = this;
    Bundle b = new Bundle();
    b.putString(TAG_BUNDLE_PARAM_NAME, windowName);
    msg.setData(b);
    mHandler.sendMessage(msg);
}

From source file:net.networksaremadeofstring.rhybudd.ViewZenossDeviceListFragment.java

public void Refresh() {
    try {/* w  w w.j  a  v a  2  s . c  o  m*/
        if (null != dialog) {
            dialog.setTitle("Contacting Zenoss...");
            dialog.setMessage("Please wait:\nLoading Infrastructure....");
            //TODO make cancelable
            dialog.setCancelable(true);

            if (!dialog.isShowing()) {
                dialog.show();
            }
        } else {
            dialog = new ProgressDialog(getActivity());
            dialog.setTitle("Contacting Zenoss...");
            dialog.setMessage("Please wait:\nLoading Infrastructure....");
            dialog.setCancelable(false);
            dialog.show();
        }
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossDeviceListFragment", "Refresh", e);
    }

    if (listOfDevices != null)
        listOfDevices.clear();

    ((Thread) new Thread() {
        public void run() {
            String MessageExtra = "";
            try {
                Message msg = new Message();
                Bundle bundle = new Bundle();

                /*ZenossAPI API = null;
                SharedPreferences settings = null;
                settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
                try
                {
                API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""));
                        
                }
                catch(ConnectTimeoutException cte)
                {
                if(cte.getMessage() != null)
                {
                        
                    bundle.putString("exception","The connection timed out;\r\n" + cte.getMessage().toString());
                    msg.setData(bundle);
                    msg.what = 0;
                    handler.sendMessage(msg);
                    //Toast.makeText(DeviceList.this, "The connection timed out;\r\n" + cte.getMessage().toString(), Toast.LENGTH_LONG).show();
                }
                else
                {
                    bundle.putString("exception","A time out error was encountered but the exception thrown contains no further information.");
                    msg.setData(bundle);
                    msg.what = 0;
                    handler.sendMessage(msg);
                    //Toast.makeText(DeviceList.this, "A time out error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show();
                }
                }
                catch(Exception e)
                {
                if(e.getMessage() != null)
                {
                    bundle.putString("exception","An error was encountered;\r\n" + e.getMessage().toString());
                    msg.setData(bundle);
                    msg.what = 0;
                    handler.sendMessage(msg);
                    //Toast.makeText(DeviceList.this, "An error was encountered;\r\n" + e.getMessage().toString(), Toast.LENGTH_LONG).show();
                }
                else
                {
                    bundle.putString("exception","An error was encountered but the exception thrown contains no further information.");
                    msg.setData(bundle);
                    msg.what = 0;
                    handler.sendMessage(msg);
                    //Toast.makeText(DeviceList.this, "An error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show();
                }
                }*/

                if (null == mService || !mBound) {
                    //Log.e("Refresh","Service was dead or something so sleeping");
                    try {
                        sleep(500);
                    } catch (Exception e) {
                        BugSenseHandler.sendExceptionMessage("ViewZenossDeviceListFragment",
                                "RefreshThreadSleep", e);
                    }
                }

                if (null == mService || !mBound) {
                    bundle.putString("exception",
                            "There was an error binding to the Rhybudd internal service to query the API. Try pressing refresh.");
                    msg.setData(bundle);
                    msg.what = 0;
                    handler.sendMessage(msg);
                } else {
                    try {

                        if (null == mService.API) {
                            mService.PrepAPI(true, true);
                        }

                        ZenossCredentials credentials = new ZenossCredentials(getActivity());

                        if (mService.API.Login(credentials)) {
                            listOfDevices = mService.API.GetRhybuddDevices();
                        }

                        /*if(API != null)
                        {
                        listOfDevices = API.GetRhybuddDevices();
                        }*/
                        else {
                            listOfDevices = null;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        if (e.getMessage() != null)
                            MessageExtra = e.getMessage();

                        listOfDevices = null;
                    }

                    if (null != listOfDevices && listOfDevices.size() > 0) {
                        PopulateMetaLists();

                        //DeviceCount = listOfZenossDevices.size();
                        Message.obtain();
                        handler.sendEmptyMessage(1);

                        RhybuddDataSource datasource = new RhybuddDataSource(getActivity());
                        datasource.open();
                        datasource.UpdateRhybuddDevices(listOfDevices);
                        datasource.close();
                    } else {
                        //Message msg = new Message();
                        //Bundle bundle = new Bundle();
                        bundle.putString("exception",
                                "A query to both the local DB and Zenoss API returned no devices. "
                                        + MessageExtra);
                        msg.setData(bundle);
                        msg.what = 0;
                        handler.sendMessage(msg);
                    }

                }
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceListFragment", "DBGetThread", e);
                //BugSenseHandler.log("DeviceList", e);
                Message msg = new Message();
                Bundle bundle = new Bundle();
                bundle.putString("exception", e.getMessage());
                msg.setData(bundle);
                msg.what = 0;
                handler.sendMessage(msg);
            }
        }
    }).start();
}

From source file:net.networksaremadeofstring.cyllell.ViewRoles_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    list = (ListView) this.getActivity().findViewById(R.id.rolesListView);
    settings = this.getActivity().getSharedPreferences("Cyllell", 0);
    try {//from w ww.java  2 s  .c om
        Cut = new Cuts(getActivity());
    } catch (Exception e) {
        e.printStackTrace();
    }

    dialog = new ProgressDialog(getActivity());
    dialog.setTitle("Contacting Chef");
    dialog.setMessage("Please wait: Prepping Authentication protocols");
    dialog.setIndeterminate(true);
    if (listOfRoles.size() < 1) {
        dialog.show();
    }

    updateListNotify = new Handler() {
        public void handleMessage(Message msg) {
            int tag = msg.getData().getInt("tag", 999999);

            if (msg.what == 0) {
                if (tag != 999999) {
                    listOfRoles.get(tag).SetSpinnerVisible();
                }
            } else if (msg.what == 1) {
                //Get rid of the lock
                CutInProgress = false;

                //the notifyDataSetChanged() will handle the rest
            } else if (msg.what == 99) {
                if (tag != 999999) {
                    Toast.makeText(ViewRoles_Fragment.this.getActivity(),
                            "An error occured during that operation.", Toast.LENGTH_LONG).show();
                    listOfRoles.get(tag).SetErrorState();
                }
            }
            RoleAdapter.notifyDataSetChanged();
        }
    };

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            //Once we've checked the data is good to use start processing it
            if (msg.what == 0) {
                OnClickListener listener = new OnClickListener() {
                    public void onClick(View v) {
                        GetMoreDetails((Integer) v.getTag());
                    }
                };

                OnLongClickListener listenerLong = new OnLongClickListener() {
                    public boolean onLongClick(View v) {
                        selectForCAB((Integer) v.getTag());
                        return true;
                    }
                };

                RoleAdapter = new RoleListAdaptor(getActivity(), listOfRoles, listener, listenerLong);
                list = (ListView) getView().findViewById(R.id.rolesListView);
                if (list != null) {
                    if (RoleAdapter != null) {
                        list.setAdapter(RoleAdapter);
                    } else {
                        //Log.e("CookbookAdapter","CookbookAdapter is null");
                    }
                } else {
                    //Log.e("List","List is null");
                }

                dialog.dismiss();
            } else if (msg.what == 200) {
                dialog.setMessage("Sending request to Chef...");
            } else if (msg.what == 201) {
                dialog.setMessage("Parsing JSON.....");
            } else if (msg.what == 202) {
                dialog.setMessage("Populating UI!");
            } else {
                //Close the Progress dialog
                dialog.dismiss();

                //Alert the user that something went terribly wrong
                AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
                alertDialog.setTitle("API Error");
                alertDialog.setMessage("There was an error communicating with the API:\n"
                        + msg.getData().getString("exception"));
                alertDialog.setButton2("Back", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        //getActivity().finish();
                    }
                });
                alertDialog.setIcon(R.drawable.icon);
                alertDialog.show();
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            if (listOfRoles.size() > 0) {
                handler.sendEmptyMessage(0);
            } else {
                try {
                    handler.sendEmptyMessage(200);
                    Roles = Cut.GetRoles();
                    handler.sendEmptyMessage(201);

                    JSONArray Keys = Roles.names();

                    for (int i = 0; i < Keys.length(); i++) {
                        listOfRoles.add(new Role(Keys.getString(i), Roles.getString(Keys.getString(i))
                                .replaceFirst("^(https://|http://).*/roles/", "")));
                    }

                    handler.sendEmptyMessage(202);
                    handler.sendEmptyMessage(0);
                } catch (Exception e) {
                    Message msg = new Message();
                    Bundle data = new Bundle();
                    data.putString("exception", e.getMessage());
                    msg.setData(data);
                    msg.what = 1;
                    handler.sendMessage(msg);
                }
            }
            return;
        }
    };

    dataPreload.start();
    return inflater.inflate(R.layout.roles_landing, container, false);
}

From source file:net.networksaremadeofstring.cyllell.ViewEnvironments_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    list = (ListView) this.getActivity().findViewById(R.id.environmentsListView);
    settings = this.getActivity().getSharedPreferences("Cyllell", 0);
    try {//from  w w w .j  a v a 2s.co m
        Cut = new Cuts(getActivity());
    } catch (Exception e) {
        e.printStackTrace();
    }

    dialog = new ProgressDialog(getActivity());
    dialog.setTitle("Contacting Chef");
    dialog.setMessage("Please wait: Prepping Authentication protocols");
    dialog.setIndeterminate(true);
    if (listOfEnvironments.size() < 1) {
        dialog.show();
    }

    updateListNotify = new Handler() {
        public void handleMessage(Message msg) {
            int tag = msg.getData().getInt("tag", 999999);

            if (msg.what == 0) {
                if (tag != 999999) {
                    listOfEnvironments.get(tag).SetSpinnerVisible();
                }
            } else if (msg.what == 1) {
                //Get rid of the lock
                CutInProgress = false;

                //the notifyDataSetChanged() will handle the rest
            } else if (msg.what == 99) {
                if (tag != 999999) {
                    Toast.makeText(ViewEnvironments_Fragment.this.getActivity(),
                            "An error occured during that operation.", Toast.LENGTH_LONG).show();
                    listOfEnvironments.get(tag).SetErrorState();
                }
            }
            EnvironmentAdapter.notifyDataSetChanged();
        }
    };

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            //Once we've checked the data is good to use start processing it
            if (msg.what == 0) {
                OnClickListener listener = new OnClickListener() {
                    public void onClick(View v) {
                        //Log.i("OnClick","Clicked");
                        GetMoreDetails((Integer) v.getTag());
                    }
                };

                OnLongClickListener listenerLong = new OnLongClickListener() {
                    public boolean onLongClick(View v) {
                        selectForCAB((Integer) v.getTag());
                        return true;
                    }
                };

                EnvironmentAdapter = new EnvironmentListAdaptor(getActivity().getBaseContext(),
                        listOfEnvironments, listener, listenerLong);
                list = (ListView) getView().findViewById(R.id.environmentsListView);
                if (list != null) {
                    if (EnvironmentAdapter != null) {
                        list.setAdapter(EnvironmentAdapter);
                    } else {
                        //Log.e("EnvironmentAdapter","EnvironmentAdapter is null");
                    }
                } else {
                    //Log.e("List","List is null");
                }

                dialog.dismiss();
            } else if (msg.what == 200) {
                dialog.setMessage("Sending request to Chef...");
            } else if (msg.what == 201) {
                dialog.setMessage("Parsing JSON.....");
            } else if (msg.what == 202) {
                dialog.setMessage("Populating UI!");
            } else {
                //Close the Progress dialog
                dialog.dismiss();

                //Alert the user that something went terribly wrong
                AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
                alertDialog.setTitle("API Error");
                alertDialog.setMessage("There was an error communicating with the API:\n"
                        + msg.getData().getString("exception"));
                alertDialog.setButton2("Back", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        getActivity().finish();
                    }
                });
                alertDialog.setIcon(R.drawable.icon);
                alertDialog.show();
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            if (listOfEnvironments.size() > 0) {
                handler.sendEmptyMessage(0);
            } else {
                try {
                    handler.sendEmptyMessage(200);
                    Environments = Cut.GetEnvironments();
                    handler.sendEmptyMessage(201);

                    JSONArray Keys = Environments.names();

                    for (int i = 0; i < Keys.length(); i++) {
                        listOfEnvironments.add(
                                new Environment(Keys.getString(i), Environments.getString(Keys.getString(i))
                                        .replaceFirst("^(https://|http://).*/environments/", "")));
                    }

                    handler.sendEmptyMessage(202);
                    handler.sendEmptyMessage(0);
                } catch (Exception e) {
                    Message msg = new Message();
                    Bundle data = new Bundle();
                    data.putString("exception", e.getMessage());
                    msg.setData(data);
                    msg.what = 1;
                    handler.sendMessage(msg);
                }
            }
            return;
        }
    };

    dataPreload.start();
    return inflater.inflate(R.layout.environments_landing, container, false);
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

private void updateMessengerBadgeCounts() {
    // SmsListdisplay mSms = new SmsListdisplay();
    final int mNewMessages = SmsListdisplay.unReadSMSCount(mContext);
    //         updateCountersForPackage("com.cognizant.trumobi", mNewMessages,
    //               R.color.PR_TEXTBOX_FOCUSED_COLOR, 2);

    Bundle b = new Bundle();

    b.putString("package", "com.cognizant.trumobi");
    b.putInt("counter", mNewMessages);
    b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR);
    b.putInt("updateCountFor", 2);
    Message m = new Message();
    m.setData(b);
    UiHandler.sendMessage(m);/*w  w w. ja va 2s  .c o  m*/

}

From source file:com.cognizant.trumobi.PersonaLauncher.java

public int getMissedCallCount() {
    String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.TYPE, CallLog.Calls.CACHED_NAME };
    missedCount = 0;/*from   w w w .j  ava 2 s  .  c  om*/
    String where = CallLog.Calls.TYPE + "=" + CallLog.Calls.MISSED_TYPE + " AND " + CallLog.Calls.NEW + "= 1 ";
    // String where =
    // CallLog.Calls.TYPE+"="+CallLog.Calls.MISSED_TYPE+" AND "+CallLog.Calls.IS_READ+"= 0 ";
    Cursor c = Email.getAppContext().getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, where,
            null, null);
    if (c != null && c.getCount() > 0 && c.moveToFirst()) {
        try {
            missedCount = c.getCount();
            DialerLog.d("MissedCall Count", "Call Count is " + missedCount);
            // new
            // com.TruBoxSDK.SharedPreferences(CognizantEmail.getAppContext()).edit().putInt("MissedCallCounts",
            // c.getCount()).commit();
        } catch (Exception e) {
            DialerLog.d("MissedCall Count", "Call Count exception" + e.getMessage());
        }

    } else {
        DialerLog.d("MissedCall Count", "Call Count is zero");
        missedCount = 0;
        // new
        // com.TruBoxSDK.SharedPreferences(CognizantEmail.getAppContext()).edit().putInt("MissedCallCounts",
        // 0).commit();

    }
    Bundle b = new Bundle();

    b.putString("package", "com.cognizant.trumobi");
    b.putInt("counter", missedCount);
    b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR);
    b.putInt("updateCountFor", 1);
    Message m = new Message();
    m.setData(b);
    UiHandler.sendMessage(m);

    return missedCount;

}

From source file:com.cognizant.trumobi.PersonaLauncher.java

private void registerIntentReceivers() {
    boolean useNotifReceiver = PersonaAlmostNexusSettingsHelper.getNotifReceiver(this);
    if (useNotifReceiver && mCounterReceiver == null) {
        mCounterReceiver = new PersonaCounterReceiver(this);
        mCounterReceiver.setCounterListener(new PersonaCounterReceiver.OnCounterChangedListener() {
            public void onTrigger(String pname, int counter, int color) {
                PersonaLog.d("personalauncher", "updateCountersForPackage called from registerIntentReceivers");
                //updateCountersForPackage(pname, counter, color, 0);
                Bundle b = new Bundle();

                b.putString("package", "com.cognizant.trumobi");
                b.putInt("counter", counter);
                b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR);
                b.putInt("updateCountFor", 0);
                Message m = new Message();
                m.setData(b);
                UiHandler.sendMessage(m);
            }/*  w w  w.  jav a2  s  .c  o m*/
        });
        registerReceiver(mCounterReceiver, mCounterReceiver.getFilter());
    }

    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    registerReceiver(mApplicationsReceiver, filter);
    filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    registerReceiver(mCloseSystemDialogsReceiver, filter);
    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    registerReceiver(mApplicationsReceiver, filter);

}