List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:net.evecom.androidecssp.activity.event.EventInfoActivity.java
/** * // www. j av a2 s . c o m * * * @author Mars zhang * @created 2015-11-23 5:32:52 */ private void initdata() { Intent intent = getIntent(); eventInfo = (BaseModel) getData("eventInfo", intent); ifqueryallevents = intent.getBooleanExtra("ifqueryallevents", true); clearFilesRecord(); String mfileids = eventInfo.getStr("eventannex"); if ("null".equals(mfileids)) { return; } String[] mids = mfileids.split(","); for (int i = 0; i < mids.length; i++) { FileManageBean fileManageBean = new FileManageBean(); fileManageBean.setFileby1(mids[i]); filebeans.add(fileManageBean); } }
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private void handleUpdatePrevent(String action, Intent intent) { String[] packages = intent.getStringArrayExtra(PreventIntent.EXTRA_PACKAGES); boolean prevent = intent.getBooleanExtra(PreventIntent.EXTRA_PREVENT, true); Map<String, Boolean> prevents = mPreventPackages; for (String name : packages) { if (prevent) { int count = countCounter(name); prevents.put(name, count == 0); } else {/*from w w w. j av a2 s.co m*/ prevents.remove(name); } } PreventListUtils.getInstance().save(mContext, mPreventPackages.keySet(), true); setResultCode(prevents.size()); setResultData(new JSONObject(prevents).toString()); LogUtils.logRequestInfo(action, null, prevents.size()); abortBroadcast(); }
From source file:com.citrus.sample.UIActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == SETTINGS_ACTION) { if (data != null) { boolean settingsChanged = data.getBooleanExtra(SettingsActivity.KEY_SETTINGS_CHANGED, false); if (settingsChanged) { Utils.updateMerchantSignatures(this); citrusClient.destroy();/*from w w w . ja va 2 s . c o m*/ citrusClient.init(Constants.SIGNUP_ID, Constants.SIGNUP_SECRET, Constants.SIGNIN_ID, Constants.SIGNIN_SECRET, Constants.VANITY, Constants.environment); String preferredEnv = Utils.getPreferredEnvironment(this); setTitle(preferredEnv + " " + app_name); citrusClient.signOut(new Callback<CitrusResponse>() { @Override public void success(CitrusResponse citrusResponse) { Utils.showToast(UIActivity.this, citrusResponse.getMessage()); } @Override public void error(CitrusError error) { Utils.showToast(UIActivity.this, error.getMessage()); } }); } } } }
From source file:com.sender.team.sender.gcm.MyGcmListenerService.java
private void chattingReceive(Bundle data) { ChattingReceiveRequest request = new ChattingReceiveRequest(this, data.getString(EXTRA_SENDER_ID), data.getString(EXTRA_CONTRACT_ID)); try {//from ww w . j a v a2 s . co m NetworkResult<ChattingReceiveData> result = NetworkManager.getInstance() .getNetworkDataSync(NetworkManager.CLIENT_STANDARD, request); ChattingReceiveData cData = result.getResult(); for (ChattingReceiveMessage c : cData.getData()) { if (!TextUtils.isEmpty(c.getMessage())) { if (c.getMessage().equals(ChattingActivity.STATE_PRODUCT_DELIVER)) { DBManager.getInstance().updateState(cData.getSender(), ChattingActivity.STATE_PRODUCT_DELIVER, Utils.convertStringToTime(c.getDate())); } else if (c.getMessage().equals(ChattingActivity.STATE_DELIVERY_COMPLETE)) { DBManager.getInstance().updateState(cData.getSender(), ChattingActivity.STATE_DELIVERY_COMPLETE, Utils.convertStringToTime(c.getDate())); } else { DBManager.getInstance().addMessage(cData.getSender(), -1, c.getUrl(), ChatContract.ChatMessage.TYPE_RECEIVE, c.getMessage(), Utils.convertStringToTime(c.getDate())); Intent i = new Intent(ACTION_CHAT); i.putExtra(EXTRA_CHAT_USER, cData.getSender()); mLBM.sendBroadcastSync(i); boolean processed = i.getBooleanExtra(EXTRA_RESULT, false); if (!processed) { if (PropertyManager.getInstance().getAlarmSetting()) { sendChatNotification(cData); sendToast(cData, c); } } } } else { DBManager.getInstance().addMessage(cData.getSender(), -1, c.getUrl(), ChatContract.ChatMessage.TYPE_PIC_RECEIVE, c.getMessage(), Utils.convertStringToTime(c.getDate())); Intent i = new Intent(ACTION_CHAT); i.putExtra(EXTRA_CHAT_USER, cData.getSender()); mLBM.sendBroadcastSync(i); boolean processed = i.getBooleanExtra(EXTRA_RESULT, false); if (!processed) { sendChatNotification(cData); sendToast(cData, c); } } } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } }
From source file:com.cellbots.eyes.EyesActivity.java
/** Called when the activity is first created. */ @Override//from w w w . ja v a 2 s . c o m public void onCreate(Bundle savedInstanceState) { Log.e("remote eyes", "started"); super.onCreate(savedInstanceState); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Cellbot Eyes"); mWakeLock.acquire(); mTorchMode = false; out = new ByteArrayOutputStream(); if ((getIntent() != null) && (getIntent().getData() != null)) { putUrl = getIntent().getData().toString(); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); Bundle extras = getIntent().getExtras(); if ((extras != null) && (extras.getBoolean("TORCH", false))) { mTorchMode = true; } } else { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); putUrl = prefs.getString("REMOTE_EYES_PUT_URL", ""); Log.e("prefs", putUrl); if (putUrl.length() < 1) { Intent i = new Intent(); i.setClass(this, PrefsActivity.class); startActivity(i); finish(); return; } else { server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); } } resetConnection(); mHttpState = new HttpState(); setContentView(R.layout.eyes_main); mPreview = (SurfaceView) findViewById(R.id.eyes_preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false); setTorchMode(useTorch); setTakePicture(shouldTakePicture); } }; this.registerReceiver(mReceiver, new IntentFilter(EyesActivity.EYES_COMMAND)); mFrame = (FrameLayout) findViewById(R.id.eyes_frame); mWebView = new WebView(this); mWebView.getSettings().setJavaScriptEnabled(true); // Use this if you want to load content locally // mWebView.loadUrl("content://com.cellbot.localpersonas/default/index.html"); mWebView.loadUrl("http://personabots.appspot.com/expressions/tuby"); mFrame.addView(mWebView); }
From source file:my.home.lehome.service.SendMsgIntentService.java
private void dispatchCommand(final Intent intent) { String cmd = intent.getStringExtra("cmdString"); String servelURL = intent.getStringExtra("serverUrl"); String deviceID = intent.getStringExtra("deviceID"); boolean local = intent.getBooleanExtra("local", false); Log.d(TAG, "dispatch cmd:" + cmd + " | servelURL:" + servelURL + " | deviceID:" + deviceID + " | local:" + local);//from w ww . j a v a 2 s .c o m final Context context = getApplicationContext(); if (local) { if (TextUtils.isEmpty(servelURL)) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.msg_local_saddress_not_set))); } } else { if (TextUtils.isEmpty(deviceID)) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.msg_no_deviceid))); } if (TextUtils.isEmpty(servelURL)) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.msg_saddress_not_set))); } } RequestFuture<String> future = RequestFuture.newFuture(); CommandRequest request = new CommandRequest(local ? Request.Method.POST : Request.Method.GET, // diff servelURL, cmd, future, future); mRequestQueue.add(request); try { String response = future.get(request.getTimeoutMs() + 10000, TimeUnit.MILLISECONDS); Log.d(TAG, "get cmd response:" + response); saveAndNotify(intent, CommandRequest.getJsonStringResponse(200, response)); } catch (ExecutionException e) { Throwable error = e.getCause(); Log.d(TAG, "get cmd error:" + error.toString()); String errorString = context.getString(R.string.error_unknown); int errorCode = 400; if (error instanceof ServerError) { errorString = context.getString(R.string.chat_error_conn); errorCode = 400; } else if (error instanceof TimeoutError) { errorString = context.getString(R.string.chat_error_http_error); errorCode = 400; } else if (error instanceof ParseError) { errorString = context.getString(R.string.chat_error_http_error); errorCode = 400; } else if (error instanceof NoConnectionError) { errorString = context.getString(R.string.chat_error_no_connection_error); errorCode = 400; } saveAndNotify(intent, CommandRequest.getJsonStringResponse(errorCode, errorString)); } catch (TimeoutException e) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.chat_error_http_error))); } catch (Exception e) { future.cancel(true); e.printStackTrace(); // saveAndNotify(intent, // CommandRequest.getJsonStringResponse( // 400, // context.getString(R.string.error_internal) // )); } }
From source file:com.jameswolfeoliver.pigeon.Services.PigeonService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); if (intent != null) { Log.i(LOG_TAG, Utils.intentToString(intent)); }//from ww w. jav a 2 s. c o m int command = intent.getIntExtra(COMMAND_KEY, Commands.COMMAND_NONE); switch (command) { case Commands.COMMAND_START: secureServer = intent.getBooleanExtra(SECURE_KEY, false); init(); break; case Commands.COMMAND_STOP: deInit(); break; case Commands.COMMAND_INFO: sendBroadcast(); case Commands.COMMAND_NONE: default: // todo } return START_NOT_STICKY; }
From source file:com.sip.pwc.sipphone.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);// w w w . j a v a 2s. co m nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }
From source file:com.csipsimple.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new NotificationCompat.Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);//w w w. java 2 s. co m nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }
From source file:com.sonetel.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new NotificationCompat.Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);//from www .jav a 2 s .c o m nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.getNotification() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }