List of usage examples for android.os Message Message
public Message()
From source file:com.norman0406.slimgress.API.Game.GameState.java
public synchronized void intHandshake(final Handler handler) { mInterface.handshake(new Handshake.Callback() { @Override/* w w w .ja va2 s .c om*/ public void handle(Handshake handshake) { mHandshake = handshake; mKnobs = mHandshake.getKnobs(); Message msg = new Message(); Bundle bundle = new Bundle(); bundle.putBoolean("Successful", mHandshake.isValid()); if (!mHandshake.isValid()) { String errString; if (mHandshake.getPregameStatus() == Handshake.PregameStatus.ClientMustUpgrade) errString = "Client must upgrade"; else if (mHandshake.getAgent() == null) errString = "Invalid agent data"; else errString = "Unknown error"; bundle.putString("Error", errString); } msg.setData(bundle); handler.sendMessage(msg); } }); }
From source file:capsrock.beta.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); timeSheet = new TimeSheet(); PebbleData = new PebbleDictionary(); //Set up to Receive messages from the pebble and handle them correctly PebbleKit.registerReceivedDataHandler(this, new PebbleKit.PebbleDataReceiver(PEBBLE_APP_UUID) { @Override/*from ww w. j av a 2s . com*/ public void receiveData(final Context context, final int transactionId, final PebbleDictionary data) { String mode = data.getString(1); //((TextView)findViewById(R.id.pebbleText)).setText(mode); if (mode.substring(9).equals("Break") || mode.substring(9).equals("Work")) { ((TimeEntryFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":0")) .onTimeEntry(findViewById(R.id.StartButton), false); } else { ((TimeEntryFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":0")) .onTimeEntry(findViewById(R.id.StopButton), false); } PebbleKit.sendAckToPebble(getApplicationContext(), transactionId); } }); //Set up the timer thread thr = new Thread(new Runnable() { @Override public void run() { while (true) { try { Thread.sleep(1000); mHandler.post(new Runnable() { @Override public void run() { Message mes = new Message(); if (strDate != null) { long seconds = Calendar.getInstance().getTimeInMillis() - strDate.getTimeInMillis(); long minutes = seconds / 1000 / 60; minutes %= 60; long hours = seconds / 1000 / 60 / 60; hours %= 24; seconds /= 1000; seconds %= 60; String sec = hours + ":" + minutes + ":" + seconds; mes.obj = sec; mHandler.sendMessage(mes); } else { mes.obj = "00:00:00"; mHandler.sendMessage(mes); } } }); } catch (Exception e) { } } } }); //Start Login Screen Intent intent = new Intent(); intent.setClassName("capsrock.beta", "capsrock.beta.LoginActivity"); //startActivity(intent); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.main.ViewPagerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final GlobalID globalID = (GlobalID) getApplication(); overridePendingTransition(R.anim.item_in, R.anim.list_out); setContentView(R.layout.activity_view_pager); mViewPager = (HackyViewPager) findViewById(R.id.view_pager); setContentView(mViewPager);/*w ww . j a v a 2s. c o m*/ work = false; if (null != savedInstanceState) { final String decode = savedInstanceState.getString("ALL_List"); index = savedInstanceState.getInt("index"); if (log) Log.e(TAG, "null != savedInstanceState ALL_List = " + decode); globalID.start(context); if (globalID.BandWArrays.isEmpty()) { globalID.PD(context, "", "..."); Thread decode_thread = new Thread() { public void run() { getTalkDataArrays(decode); Message msg = new Message(); globalID.TalkList = ALL_List; mhandler.sendMessage(msg); } }; decode_thread.start(); } } else { Intent intent = getIntent(); Bundle data = intent.getExtras(); index = data.getInt("i"); ALL_List = globalID.TalkList; work = true; } samplePagerAdapter = new SamplePagerAdapter(ViewPagerActivity.this, IMG_List); mViewPager.setAdapter(samplePagerAdapter); samplePagerAdapter.notifyDataSetChanged(); Thread check = new Thread() { public void run() { while (!work) { try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); continue; } } for (int i = 0; i < ALL_List.size(); i++) { TalkEntity entity = ALL_List.get(i); if (!entity.getIsMsg()) { Message msg = new Message(); msg.what = i; msg.obj = entity; add_img_handler.sendMessage(msg); } } } }; check.start(); }
From source file:com.aquatest.dbinterface.tools.DatabaseUpdater.java
/** * Send message from this thread using preset handler * // w ww . j a v a2 s.co m * @param s * message to be sent * @param _code * code of the message for handler to be able to determine the * type of message */ public void sendMessage(String s, int code) { Bundle b = new Bundle(); b.putString("msg", s); if (h != null) { Message msg = new Message(); msg.setData(b); msg.what = code; h.sendMessage(msg); } }
From source file:com.android.wako.net.BaseRequest.java
public void sendData() { if (!Constants.IS_STOP_REQUEST) { Message msg = new Message(); msg.obj = ret;// w ww. j a v a 2 s . co m msg.getData().putSerializable("callback", callBack); resultHandler.sendMessage(msg); } }
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 *//*from w ww. ja v a 2s. c o 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:com.cleanwiz.applock.ui.activity.FeedbackActivity.java
private void sync() { mComversation.sync(new SyncListener() { @Override/* w ww . j a v a 2 s.c o m*/ public void onSendUserReply(List<Reply> replyList) { } @Override public void onReceiveDevReply(List<Reply> replyList) { mSwipeRefreshLayout.setRefreshing(false); if (replyList == null || replyList.size() < 1) { return; } mHandler.sendMessage(new Message()); mListView.setSelection(mComversation.getReplyList().size()); } }); }
From source file:com.batontouch.facebook.SessionStore.java
private static void FacebookServerLogin(String token) { Log.d("my", token); HashMap<String, String> sessionTokens = null; mPreferences = mcontext.getSharedPreferences("CurrentUser", mcontext.MODE_PRIVATE); DefaultHttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(Global.FacebookSendToken + token + "®id=" + Global.gcm_regid); get.setHeader("Accept", "application/vnd.batontouch." + Global.version); String response = null;//from w w w .jav a2 s. c om try { ResponseHandler<String> responseHandler = new BasicResponseHandler(); response = client.execute(get, responseHandler); } catch (ClientProtocolException e) { Log.e("my", e.getClass().getName() + e.getMessage() + " clpt"); } catch (IOException e) { Log.e("my", e.getClass().getName() + e.getMessage() + " IO"); } catch (Exception e) { Log.e("my", e.getClass().getName() + e.getMessage() + " exception"); } ParsedLoginDataSet parsedLoginDataSet = new ParsedLoginDataSet(); try { sessionTokens = parseToken(response); } catch (Exception e) { Log.e("my", e.getClass().getName() + e.getMessage() + "5"); } parsedLoginDataSet.setExtractedString(sessionTokens.get("error")); if (parsedLoginDataSet.getExtractedString().equals("Success")) { GCMRegistrar.setRegisteredOnServer(mcontext, true); // Store the username and password in SharedPreferences after the // successful login SharedPreferences.Editor editor = mPreferences.edit(); // editor.putString("UserName", email); // editor.putString("PassWord", password); editor.putString("AuthToken", sessionTokens.get("auth_token")); editor.commit(); Message myMessage = new Message(); myMessage.obj = "SUCCESS"; handler.sendMessage(myMessage); } else { Log.e("my", "Login Error!"); } }
From source file:com.example.sajid.myapplication.ChatConnection.java
public synchronized void updateMessages(String msg, boolean local) { Log.e(TAG, "Updating message: " + msg); Bundle messageBundle = new Bundle(); messageBundle.putString("msg", msg); byte[] bytes = new byte[0]; Message message = new Message(); message.setData(messageBundle);// ww w . j a v a 2 s. com mUpdateHandler.sendMessage(message); }
From source file:com.softminds.matrixcalculator.OperationFragments.ExponentFragment.java
public void RunAndGetResult(final int pos, final int exponent, final ProgressDialog progressDialog) { Runnable runnable = new Runnable() { @Override//from w ww . jav a 2 s . co m public void run() { MatrixV2 res = new MatrixV2( ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos) .getNumberOfRows(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos) .getNumberOfCols(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos).getType()); res.cloneFrom(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos)); res.raisedToPower(exponent); progressDialog.dismiss(); Message message = new Message(); message.setData(res.getDataBundled()); handler.sendMessage(message); } }; Thread thread = new Thread(runnable); thread.start(); }