List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.nks.nksmod.otaupdater.DownloadReceiver.java
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action == null) return;//from w w w . j a v a 2s.c o m if (action.equals(DL_ROM_ACTION)) { RomInfo.FACTORY.clearUpdateNotif(context); RomInfo.FACTORY.fromIntent(intent).startDownload(context); /* } else if (action.equals(DL_KERNEL_ACTION)) { KernelInfo.FACTORY.clearUpdateNotif(context); KernelInfo.FACTORY.fromIntent(intent).startDownload(context); */ } else if (action.equals(CLEAR_DL_ACTION)) { if (intent.hasExtra(DownloadManager.EXTRA_DOWNLOAD_ID)) { DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); dm.remove(intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)); DownloadBarFragment.notifyActiveFragment(); } } else if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) { DownloadStatus status = DownloadStatus.forDownloadID(context, intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)); if (status == null) return; BaseInfo info = status.getInfo(); if (info == null) return; int error = status.getStatus() == DownloadManager.STATUS_SUCCESSFUL ? info.checkDownloadedFile() : status.getReason(); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (error == 0) { Intent mainIntent = new Intent(context, OTAUpdaterActivity.class); mainIntent.setAction(info.getNotifAction()); mainIntent.putExtra(OTAUpdaterActivity.EXTRA_FLAG_DOWNLOAD_DIALOG, true); PendingIntent mainPIntent = PendingIntent.getActivity(context, 0, mainIntent, PendingIntent.FLAG_CANCEL_CURRENT); Intent flashIntent = new Intent(context, DownloadsActivity.class); flashIntent.setAction(info.getFlashAction()); info.addToIntent(flashIntent); PendingIntent flashPIntent = PendingIntent.getActivity(context, 0, flashIntent, PendingIntent.FLAG_CANCEL_CURRENT); Notification notif = new NotificationCompat.Builder(context) .setTicker(context.getString(info.getDownloadDoneTitle())) .setContentTitle(context.getString(info.getDownloadDoneTitle())) .setSmallIcon(R.drawable.ic_stat_av_download) .setContentText(context.getString(R.string.notif_completed)).setContentIntent(mainPIntent) .addAction(R.drawable.ic_action_system_update, context.getString(R.string.install), flashPIntent) .build(); nm.notify(info.getFlashNotifID(), notif); } else { Intent mainIntent = new Intent(context, OTAUpdaterActivity.class); mainIntent.setAction(info.getNotifAction()); info.addToIntent(mainIntent); PendingIntent mainPIntent = PendingIntent.getActivity(context, 0, mainIntent, PendingIntent.FLAG_CANCEL_CURRENT); Intent dlIntent = new Intent(context, DownloadReceiver.class); dlIntent.setAction(info.getDownloadAction()); info.addToIntent(dlIntent); PendingIntent dlPIntent = PendingIntent.getBroadcast(context, 1, dlIntent, PendingIntent.FLAG_CANCEL_CURRENT); Intent clearIntent = new Intent(context, DownloadReceiver.class); clearIntent.setAction(CLEAR_DL_ACTION); clearIntent.putExtra(DownloadManager.EXTRA_DOWNLOAD_ID, status.getId()); PendingIntent clearPIntent = PendingIntent.getBroadcast(context, 2, clearIntent, PendingIntent.FLAG_CANCEL_CURRENT); Notification notif = new NotificationCompat.Builder(context) .setTicker(context.getString(info.getDownloadFailedTitle())) .setContentTitle(context.getString(info.getDownloadFailedTitle())) .setContentText(status.getErrorString(context)).setSmallIcon(R.drawable.ic_stat_warning) .setContentIntent(mainPIntent).setDeleteIntent(clearPIntent) .addAction(R.drawable.ic_action_refresh, context.getString(R.string.retry), dlPIntent) .build(); nm.notify(info.getFailedNotifID(), notif); } } else if (action.equals(DownloadManager.ACTION_NOTIFICATION_CLICKED)) { long[] ids = intent.getLongArrayExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS); if (ids.length == 0) return; DownloadStatus status = DownloadStatus.forDownloadID(context, ids[0]); if (status == null) return; BaseInfo info = status.getInfo(); if (info == null) return; Intent i = new Intent(context, OTAUpdaterActivity.class); i.setAction(info.getNotifAction()); i.putExtra(OTAUpdaterActivity.EXTRA_FLAG_DOWNLOAD_DIALOG, true); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } }
From source file:com.ichi2.anki.Feedback.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); Resources res = getResources(); Context context = getBaseContext(); SharedPreferences sharedPreferences = AnkiDroidApp.getSharedPrefs(context); mReportErrorMode = sharedPreferences.getString("reportErrorMode", REPORT_ASK); mNonce = UUID.randomUUID().getMostSignificantBits(); mFeedbackUrl = res.getString(R.string.feedback_post_url); mErrorUrl = res.getString(R.string.error_post_url); mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mPostingFeedback = false;/*from w w w . java 2 s . com*/ initAllAlertDialogs(); getErrorFiles(); Intent i = getIntent(); mAllowFeedback = (i.hasExtra("request") && (i.getIntExtra("request", 0) == DeckPicker.REPORT_FEEDBACK || i.getIntExtra("request", 0) == DeckPicker.RESULT_DB_ERROR)) || mReportErrorMode.equals(REPORT_ASK); if (!mAllowFeedback) { if (mReportErrorMode.equals(REPORT_ALWAYS)) { // Always report try { String feedback = "Automatically sent"; Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), true })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } } catch (Exception e) { Log.e(AnkiDroidApp.TAG, e.toString()); } finish(); ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); return; } else if (mReportErrorMode.equals(REPORT_NEVER)) { // Never report deleteFiles(false, false); finish(); ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); return; } } View mainView = getLayoutInflater().inflate(R.layout.feedback, null); setContentView(mainView); Themes.setWallpaper(mainView); Themes.setTextViewStyle(findViewById(R.id.tvFeedbackDisclaimer)); Themes.setTextViewStyle(findViewById(R.id.lvFeedbackErrorList)); Button btnSend = (Button) findViewById(R.id.btnFeedbackSend); Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest); Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll); mEtFeedbackText = (EditText) findViewById(R.id.etFeedbackText); mLvErrorList = (ListView) findViewById(R.id.lvFeedbackErrorList); mErrorAdapter = new SimpleAdapter(this, mErrorReports, R.layout.error_item, new String[] { "name", "state", "result" }, new int[] { R.id.error_item_text, R.id.error_item_progress, R.id.error_item_status }); mErrorAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { switch (view.getId()) { case R.id.error_item_progress: if (text.equals(STATE_UPLOADING)) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } return true; case R.id.error_item_status: if (text.length() == 0) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } return false; } }); btnClearAll.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, false); refreshErrorListView(); refreshInterface(); } }); mLvErrorList.setAdapter(mErrorAdapter); btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mPostingFeedback) { String feedback = mEtFeedbackText.getText().toString(); Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), false })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } refreshInterface(); } } }); btnKeepLatest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, true); refreshErrorListView(); refreshInterface(); } }); refreshInterface(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); }
From source file:com.globalcollect.gateway.sdk.client.android.exampleapp.fragments.FullWalletConfirmationButtonFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { mProgressDialog.hide();/*from w ww. j a v a2s . com*/ // retrieve the error code, if available int errorCode = -1; if (data != null) { errorCode = data.getIntExtra(WalletConstants.EXTRA_ERROR_CODE, -1); } switch (requestCode) { case REQUEST_CODE_RESOLVE_LOAD_FULL_WALLET: switch (resultCode) { case Activity.RESULT_OK: if (data != null && data.hasExtra(WalletConstants.EXTRA_FULL_WALLET)) { FullWallet fullWallet = data.getParcelableExtra(WalletConstants.EXTRA_FULL_WALLET); // the full wallet can now be used to process the customer's payment // send the wallet info up to server to process, and to get the result // for sending a transaction status fetchTransactionStatus(fullWallet); } else if (data != null && data.hasExtra(WalletConstants.EXTRA_MASKED_WALLET)) { // re-launch the activity with new masked wallet information mMaskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET); mActivityLaunchIntent.putExtra(Constants.INTENT_MASKED_WALLET, mMaskedWallet); startActivity(mActivityLaunchIntent); } break; case Activity.RESULT_CANCELED: // nothing to do here break; default: handleError(errorCode); break; } break; } }
From source file:de.da_sense.moses.client.WelcomeActivity.java
@Override protected void onResume() { super.onResume(); /*/*w w w. jav a2 s .c o m*/ * Register the RECEIVER for receiving informations about connectivity * to Internet ############## */ mConnReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { Log.i(LOG_TAG, "Internet connection changed"); ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo currentNetworkInfo = cm.getActiveNetworkInfo(); // go through all Fragments and inform the ones implementing the // InternetConnectionChangeListener for (WeakReference<Fragment> fragRef : mFragList) { Fragment fragment = fragRef.get(); if (fragment != null && fragment instanceof InternetConnectionChangeListener) { InternetConnectionChangeListener listener = (InternetConnectionChangeListener) fragment; if (currentNetworkInfo != null && currentNetworkInfo.isConnected()) { Log.d(LOG_TAG, "Informing a fragment about the establishment of the Internet connection"); listener.onConnectionEstablished(); } else { Log.d(LOG_TAG, "Informing a fragment about the loss of the Internet connection"); listener.onConnectionLost(); } } } } }; registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); /* * RECEIVER END * ######################################################### * #################### */ checkInstalledStatesOfApks(); Intent startingIntent = getIntent(); if (startingIntent.hasExtra(WelcomeActivity.KEY_VIEW_SURVEY)) { // some other activity has started this activity in order to show an // available survey, just scroll // to running fragment and let him do the rest mViewPager.setCurrentItem(WelcomeActivityPagerAdapter.TAB_RUNNING, true); } }
From source file:ch.fixme.status.Main.java
private void showHsInfo(Intent intent, Bundle savedInstanceState) { // Get hackerspace api url if (intent != null && intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) { mApiUrl = mPrefs.getString(PREF_API_URL_WIDGET + intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID), ParseGeneric.API_DEFAULT); } else if (intent != null && intent.hasExtra(STATE_HS)) { mApiUrl = intent.getStringExtra(STATE_HS); } else {//w w w. j av a 2 s . c o m mApiUrl = mPrefs.getString(PREF_API_URL, ParseGeneric.API_DEFAULT); } // Get Data final Bundle data = (Bundle) getLastNonConfigurationInstance(); if (data == null || (savedInstanceState == null && !savedInstanceState.containsKey(STATE_HS))) { getApiTask = new GetApiTask(); getApiTask.execute(mApiUrl); } else { finishApi = true; mResultHs = data.getString(STATE_HS); populateDataHs(); } // Update widget Widget.UpdateAllWidgets(getApplicationContext()); }
From source file:com.hichinaschool.flashcards.anki.Feedback.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); Resources res = getResources(); Context context = getBaseContext(); SharedPreferences sharedPreferences = AnkiDroidApp.getSharedPrefs(context); mReportErrorMode = sharedPreferences.getString("reportErrorMode", REPORT_ASK); mNonce = UUID.randomUUID().getMostSignificantBits(); mFeedbackUrl = res.getString(R.string.feedback_post_url); mErrorUrl = res.getString(R.string.error_post_url); mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mPostingFeedback = false;/*from ww w. java2s . c o m*/ initAllAlertDialogs(); getErrorFiles(); Intent i = getIntent(); mAllowFeedback = (i.hasExtra("request") && (i.getIntExtra("request", 0) == DeckPicker.REPORT_FEEDBACK || i.getIntExtra("request", 0) == DeckPicker.RESULT_DB_ERROR)) || mReportErrorMode.equals(REPORT_ASK); if (!mAllowFeedback) { if (mReportErrorMode.equals(REPORT_ALWAYS)) { // Always report try { String feedback = "Automatically sent"; Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), true })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } } catch (Exception e) { Log.e(AnkiDroidApp.TAG, e.toString()); } finish(); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); } return; } else if (mReportErrorMode.equals(REPORT_NEVER)) { // Never report deleteFiles(false, false); finish(); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); } return; } } View mainView = getLayoutInflater().inflate(R.layout.feedback, null); setContentView(mainView); Themes.setWallpaper(mainView); Themes.setTextViewStyle(findViewById(R.id.tvFeedbackDisclaimer)); Themes.setTextViewStyle(findViewById(R.id.lvFeedbackErrorList)); Button btnSend = (Button) findViewById(R.id.btnFeedbackSend); Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest); Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll); mEtFeedbackText = (EditText) findViewById(R.id.etFeedbackText); mLvErrorList = (ListView) findViewById(R.id.lvFeedbackErrorList); mErrorAdapter = new SimpleAdapter(this, mErrorReports, R.layout.error_item, new String[] { "name", "state", "result" }, new int[] { R.id.error_item_text, R.id.error_item_progress, R.id.error_item_status }); mErrorAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { switch (view.getId()) { case R.id.error_item_progress: if (text.equals(STATE_UPLOADING)) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } return true; case R.id.error_item_status: if (text.length() == 0) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } return false; } }); btnClearAll.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, false); refreshErrorListView(); refreshInterface(); } }); mLvErrorList.setAdapter(mErrorAdapter); btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mPostingFeedback) { String feedback = mEtFeedbackText.getText().toString(); Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), false })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } refreshInterface(); } } }); btnKeepLatest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, true); refreshErrorListView(); refreshInterface(); } }); refreshInterface(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); }
From source file:com.synox.android.files.services.FileDownloader.java
/** * Entry point to add one or several files to the queue of downloads. * <p/>//from w w w. jav a2 s .co m * New downloads are added calling to startService(), resulting in a call to this method. * This ensures the service will keep on working although the caller activity goes away. */ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE)) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); final OCFile file = intent.getParcelableExtra(EXTRA_FILE); AbstractList<String> requestedDownloads = new Vector<>(); try { DownloadFileOperation newDownload = new DownloadFileOperation(account, file); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); Pair<String, String> putResult = mPendingDownloads.putIfAbsent(account, file.getRemotePath(), newDownload); String downloadKey = putResult.first; requestedDownloads.add(downloadKey); // Store file on db with state 'downloading' /* TODO - check if helps with UI responsiveness, letting only folders use FileDownloaderBinder to check FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver()); file.setDownloading(true); storageManager.saveFile(file); */ sendBroadcastNewDownload(newDownload, putResult.second); } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } if (requestedDownloads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedDownloads; mServiceHandler.sendMessage(msg); } //} } return START_NOT_STICKY; }
From source file:com.lhtechnologies.DoorApp.AuthenticatedReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.e(this.getClass().getSimpleName(), "Received Broadcast!"); if (intent.getAction().equals(AuthenticationFinishedBroadCast)) { String reason;//from w ww . j a va 2s . c o m mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //Start the notification NotificationCompat.Builder notiBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(context.getString(R.string.app_name)); if (intent.hasExtra(AuthenticatorReturnCode)) { String returnCode = intent.getStringExtra(AuthenticatorReturnCode); if (returnCode.equals(ServerReturnSuccess)) { if (intent.hasExtra(FlatDoor)) { notiBuilder.setContentText(context.getString(R.string.StatusBuzzing)).setOngoing(true) .setDefaults(Notification.FLAG_SHOW_LIGHTS).setLights(0xFF00FF00, 1000, 1000); mNotificationManager.notify(BuzzingNotificationId, notiBuilder.build()); class RemoveBuzzingNotification extends TimerTask { public void run() { mNotificationManager.cancel(BuzzingNotificationId); timer.cancel(); //Terminate the timer thread } } timer = new Timer(); timer.schedule(new RemoveBuzzingNotification(), buzzerTimeout * 1000); } else { notiBuilder.setContentText(context.getString(R.string.StatusAuthenticated)).setOngoing(true) .setDefaults(Notification.FLAG_SHOW_LIGHTS).setLights(0xFF00FF00, 1000, 1000); mNotificationManager.notify(SuccessNotificationId, notiBuilder.build()); class RemoveSuccessNotification extends TimerTask { public void run() { mNotificationManager.cancel(SuccessNotificationId); timer.cancel(); //Terminate the timer thread } } timer = new Timer(); timer.schedule(new RemoveSuccessNotification(), timeout * 1000); } } else { String result = intent.getStringExtra(AuthenticatorReturnCode); if (result.equals(ServerReturnAuthFailure)) reason = context.getString(R.string.AuthFailureExplanantion); else if (result.equals(ServerReturnInternalFailure)) reason = context.getString(R.string.InternalFailureExplanantion); else if (result.equals(ServerReturnRegistrationStarted)) reason = context.getString(R.string.RegistrationStartedExplanantion); else if (result.equals(ServerReturnRegistrationPending)) reason = context.getString(R.string.RegistrationPendingExplanantion); else if (result.equals(ClientErrorUndefined)) reason = context.getString(R.string.ClientErrorExplanantion) + "\n" + intent.getStringExtra(AuthenticatorErrorDescription); else if (result.equals(ClientErrorMalformedURL)) reason = context.getString(R.string.MalformedURLExplanation); else reason = context.getString(R.string.UnknownErrorExplanation); notiBuilder .setContentText(reason).setOngoing(false).setDefaults(Notification.FLAG_SHOW_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(0xFFFF0000, 500, 500); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, MainActivity.class); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notiBuilder.setContentIntent(resultPendingIntent); mNotificationManager.notify(FailureNotificationId, notiBuilder.build()); } } else { reason = context.getString(R.string.AuthFailureExplanantion) + "\n" + "NO_EXTRA"; notiBuilder .setContentText(reason).setOngoing(false).setDefaults(Notification.FLAG_SHOW_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(0xFFFF0000, 500, 500); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, MainActivity.class); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notiBuilder.setContentIntent(resultPendingIntent); mNotificationManager.notify(FailureNotificationId, notiBuilder.build()); } abortBroadcast(); } }
From source file:com.vantiv.android.gms.samples.wallet.FullWalletConfirmationButtonFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { mProgressDialog.hide();//w w w . j a v a2s . c o m // retrieve the error code, if available int errorCode = -1; if (data != null) { errorCode = data.getIntExtra(WalletConstants.EXTRA_ERROR_CODE, -1); } switch (requestCode) { case REQUEST_CODE_RESOLVE_LOAD_FULL_WALLET: switch (resultCode) { case Activity.RESULT_OK: if (data != null && data.hasExtra(WalletConstants.EXTRA_FULL_WALLET)) { FullWallet fullWallet = data.getParcelableExtra(WalletConstants.EXTRA_FULL_WALLET); // the full wallet can now be used to process the customer's payment // send the wallet info up to server to process, and to get the result // for sending a transaction status fetchTransactionStatus(fullWallet); } else if (data != null && data.hasExtra(WalletConstants.EXTRA_MASKED_WALLET)) { // re-launch the activity with new masked wallet information mMaskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET); mActivityLaunchIntent.putExtra(Constants.EXTRA_MASKED_WALLET, mMaskedWallet); startActivity(mActivityLaunchIntent); } break; case Activity.RESULT_CANCELED: // nothing to do here break; default: handleError(errorCode); break; } break; } }
From source file:auribises.com.visitorbook.Activites.VisitorEntryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_visitor_entry); ButterKnife.inject(this); preferences = getSharedPreferences(Util.PREFS_NAME, MODE_PRIVATE); editor = preferences.edit();//w w w . ja v a 2s. co m progressDialog = new ProgressDialog(this); progressDialog.setMessage("Please Wait.."); progressDialog.setCancelable(false); visitorentry = new Visitorentry(); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item); adapter.add("--Select Branch--"); adapter.add("Applied Sciences"); adapter.add("Civil Engineering"); adapter.add("Electrical Engineering"); adapter.add("Mechanical Engineering"); adapter.add("Electroncis & Communication Engineering"); adapter.add("Computer Science & Engineering"); adapter.add("Information Technology"); adapter.add("Production Engineering"); adapter.add("Business Administration"); adapter.add("Computer Applications"); ; spBranch.setAdapter(adapter); spBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (i != 0) { visitorentry.setBranch(adapter.getItem(i)); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item); adapter1.add("--Select IDProof--"); adapter1.add("Aadhar Card"); adapter1.add("License"); adapter1.add("PAN Card"); adapter1.add("Voter Card"); spIDProof.setAdapter(adapter1); spIDProof.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (i != 0) { visitorentry.setIDProof(adapter1.getItem(i)); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item); adapter2.add("--Vehicle Type--"); adapter2.add("Car"); adapter2.add("Bike"); adapter2.add("Activa"); adapter2.add("Auto"); adapter2.add("Bus"); spVehicle.setAdapter(adapter2); spVehicle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (i != 0) { visitorentry.setVehicle(adapter2.getItem(i)); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); rbMale.setOnCheckedChangeListener(this); rbFemale.setOnCheckedChangeListener(this); resolver = getContentResolver(); requestQueue = Volley.newRequestQueue(this); Intent rcv = getIntent(); updateMode = rcv.hasExtra("keyVisitorentry"); if (updateMode) { rcvVisitorentry = (Visitorentry) rcv.getSerializableExtra("keyVisitorentry"); eTxtName.setText(rcvVisitorentry.getName()); eTxtPhone.setText(rcvVisitorentry.getPhone()); eTxtEmail.setText(rcvVisitorentry.getEmail()); eTxtAddress.setText(rcvVisitorentry.getAddress()); eTxtPurpose.setText(rcvVisitorentry.getPurpose()); eTxtDate.setText(rcvVisitorentry.getDate()); eTxtTime.setText(rcvVisitorentry.getTime()); eTxtTeacher.setText(rcvVisitorentry.getTeacher()); eTxtIDProofNumber.setText(rcvVisitorentry.getIDProofnumber()); eTxtVehicleNumber.setText(rcvVisitorentry.getVehiclenumber()); if (rcvVisitorentry.getGender().equals("Male")) { rbMale.setChecked(true); } else { rbFemale.setChecked(true); } Log.i("TEST", adapter + " - " + rcvVisitorentry.getBranch() + " - " + rcvVisitorentry.getIDProof() + " - " + rcvVisitorentry.getVehicle()); int p = 0; for (int i = 0; i < adapter.getCount(); i++) { if (adapter.getItem(i).equals(rcvVisitorentry.getBranch())) { Log.i("TEST1", adapter.getItem(i) + " - " + rcvVisitorentry.getBranch()); p = i; break; } } spBranch.setSelection(p); int q = 0; for (int i = 0; i < adapter1.getCount(); i++) { if (adapter1.getItem(i).equals(rcvVisitorentry.getIDProof())) { Log.i("TEST2", adapter1.getItem(i) + " - " + rcvVisitorentry.getIDProof()); q = i; break; } } spIDProof.setSelection(q); int r = 0; for (int i = 0; i < adapter2.getCount(); i++) { if (adapter2.getItem(i).equals(rcvVisitorentry.getVehicle())) { Log.i("TEST3", adapter2.getItem(i) + " - " + rcvVisitorentry.getVehicle()); r = i; break; } } spVehicle.setSelection(r); btnSubmit.setText("Update"); } }