Example usage for android.content Intent putExtras

List of usage examples for android.content Intent putExtras

Introduction

In this page you can find the example usage for android.content Intent putExtras.

Prototype

public @NonNull Intent putExtras(@NonNull Bundle extras) 

Source Link

Document

Add a set of extended data to the intent.

Usage

From source file:com.parse.CN1ParsePushBroadcastReceiver.java

@Override
protected void onPushReceive(Context context, Intent intent) {
    /*/*  w  w  w . j  a  v  a 2  s  .  c o  m*/
     Adapted from ParsePushBroadcastReceiver.onPushReceived(). Main changes:
     1. Implemented callbacks to ParsePush with the push payload based on
    app state
     */

    JSONObject pushData = null;
    try {
        pushData = new JSONObject(intent.getStringExtra(ParsePushBroadcastReceiver.KEY_PUSH_DATA));
    } catch (JSONException e) {
        writeErrorLog("Unexpected JSONException when parsing received push data:\n" + e);
    }
    writeDebugLog("Push received: " + (pushData == null ? "<no payload>" : pushData.toString()));

    boolean handled = false;
    if (pushData != null && CN1AndroidApplication.isAppRunning()) {
        if (CN1AndroidApplication.isAppInForeground()) {
            writeDebugLog("App in foreground; will allow app to directly handle push message, if desired");
            handled = ParsePush.handlePushReceivedForeground(pushData.toString());
        } else if (CN1AndroidApplication.isAppInBackground()) {
            writeDebugLog("App in background; will allow app to directly handle push message, if desired");
            handled = ParsePush.handlePushReceivedBackground(pushData.toString());
        }
    }

    if (!handled) {
        // If the push data includes an action string, that broadcast intent is fired.
        String action = null;
        if (pushData != null) {
            action = pushData.optString("action", null);
        }
        if (action != null) {
            writeDebugLog("Firing broadcast for action " + action);
            Bundle extras = intent.getExtras();
            Intent broadcastIntent = new Intent();
            broadcastIntent.putExtras(extras);
            broadcastIntent.setAction(action);
            broadcastIntent.setPackage(context.getPackageName());
            context.sendBroadcast(broadcastIntent);
        }

        Notification notification = getNotification(context, intent);

        if (notification != null) {
            writeDebugLog("Scheduling notification for push message since it was not handled by app");
            ParseNotificationManager.getInstance().showNotification(context, notification);
        } else {
            // If, for any reason, creating the notification fails (typically because
            // the push is a 'hidden' push with no alert/title fields),
            // store it for later processing.
            if (pushData != null) {
                writeDebugLog("Requesting ParsePush to handle unprocessed (hidden?) push message");
                ParsePush.handleUnprocessedPushReceived(pushData.toString());
            }
        }
    } else {
        writeDebugLog("Push already handled by app so not scheduling any notification");
    }
}

From source file:com.cnlms.wear.datalayerapi.DataLayerListenerService.java

private void startBoardingPassActivity(final DataMap dataMap) {

    log("starting boarding pass");

    final Intent boardingPassIntent = new Intent(this, BoardingPassActivity.class);
    boardingPassIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    boardingPassIntent.putExtras(dataMap.toBundle());

    startActivity(boardingPassIntent);/* ww  w .ja  v a2s .  c  o m*/

}

From source file:br.ufsc.das.gtscted.shibbauth.SPSelectionActivity.java

/** Called when the activity is first created. */
@Override//from  w w w .  j  av a2  s .  co  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sp_selection);

    nextButton = (Button) findViewById(R.id.nextButton);
    exitButton = (Button) findViewById(R.id.exitButton);
    spEditText = (EditText) findViewById(R.id.spUrlEditText);

    //SP para testes   
    spEditText.setText("https://sp.ufrgs.br/chimarrao/");

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String serviceUrl = spEditText.getText().toString();

            try {
                Connection connection = new Connection();
                String[] getResponseAndEndpoint = connection.httpGetWithEndpoint(serviceUrl);
                String wayfLocation = getResponseAndEndpoint[0];
                String responseBody = getResponseAndEndpoint[1];

                Bundle bundle = new Bundle();
                bundle.putString("html_source", responseBody);
                bundle.putString("wayf_location", wayfLocation);
                bundle.putSerializable("cookie", connection.getSerializableCookie(0));

                Intent newIntent = new Intent(SPSelectionActivity.this, ShibAuthenticationActivity.class);
                newIntent.putExtras(bundle);
                startActivity(newIntent);

            } catch (KeyManagementException e) {
                String message = "KeyManagementException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (NoSuchAlgorithmException e) {
                String message = "NoSuchAlgorithmException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (KeyStoreException e) {
                String message = "KeyStoreException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (UnrecoverableKeyException e) {
                String message = "UnrecoverableKeyException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (ClientProtocolException e) {
                String message = "ClientProtocolException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (IOException e) {
                String message = "IOException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (Exception e) {
                String message = "Exception";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            }
        }
    });

    exitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.cloudkick.DashboardActivity.java

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Bundle data = new Bundle();
    data.putSerializable("node", nodes.get(position));
    Intent intent = new Intent(DashboardActivity.this, NodeViewActivity.class);
    intent.putExtras(data);
    startActivity(intent);//from www. ja  v  a2  s . c  o m
}

From source file:com.boko.vimusic.ui.fragments.GenreFragment.java

/**
 * {@inheritDoc}//from  w w w  .j  a v a2  s.c  o  m
 */
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
    mGenre = mAdapter.getItem(position);
    // Create a new bundle to transfer the artist info
    final Bundle bundle = new Bundle();
    if (mGenre.getId() != null) {
        bundle.putString(Config.ID, mGenre.getId());
    }
    bundle.putString(Config.MIME_TYPE, MediaStore.Audio.Genres.CONTENT_TYPE);
    bundle.putString(Config.NAME, mGenre.getName());

    // Create the intent to launch the profile activity
    final Intent intent = new Intent(getActivity(), ProfileActivity.class);
    intent.putExtras(bundle);
    startActivity(intent);
}

From source file:com.android.email.activity.zx.MessageView.java

public static void actionView(Context context, Account account, String folder, String messageUid,
        ArrayList<String> folderUids, Bundle extras) {
    Intent i = new Intent(context, MessageView.class);
    i.putExtra(EXTRA_ACCOUNT, account);/*from ww w  . j  av  a 2 s . c om*/
    i.putExtra(EXTRA_FOLDER, folder);
    i.putExtra(EXTRA_MESSAGE, messageUid);
    i.putExtra(EXTRA_FOLDER_UIDS, folderUids);
    if (extras != null) {
        i.putExtras(extras);
    }
    context.startActivity(i);
}

From source file:love.juhe.androidmonkey.MonkeyActivityEvent.java

@SuppressLint("NewApi")
@Override//w  w  w . j a v  a  2s. c o  m
public int fireEvent(Instrumentation testRuner) {
    Intent intent = getEvent();
    MonkeyLog.l(":Switch: " + intent.toUri(0));

    if (mAlarmTime != 0) {
        Bundle args = new Bundle();
        args.putLong("alarmTime", mAlarmTime);
        intent.putExtras(args);
    }
    try {
        //         IntentFilter filter = new IntentFilter(getEvent().getAction());
        //         ActivityMonitor monitor = testRuner.addMonitor(filter, null, true);
        testRuner.startActivitySync(intent);
        //         testRuner.waitForMonitorWithTimeout(monitor, 10);

    } catch (SecurityException e) {
        MonkeyLog.l("** Permissions error starting activity " + intent.toUri(0));
        return MonkeyEvent.INJECT_ERROR_SECURITY_EXCEPTION;
    }
    return MonkeyEvent.INJECT_SUCCESS;
}

From source file:de.incoherent.suseconferenceclient.tasks.CheckForUpdatesTask.java

@Override
protected Long doInBackground(Void... params) {
    String kUrl = "https://conference.opensuse.org/osem/api/v1/conferences/gRNyOIsTbvCfJY5ENYovBA";
    if (kUrl.length() <= 0)
        return 0l;

    String updatesUrl = mConference.getUrl() + "/updates.json";
    int lastUpdateRevision = mDb.getLastUpdateValue(mConference.getSqlId());
    int revisionLevel = lastUpdateRevision;

    try {//from w w  w . j a va  2 s .c  o m
        JSONObject updateReply = HTTPWrapper.get(updatesUrl);
        if (updateReply == null)
            return 0l;
        int newLevel = updateReply.getInt("revision");
        if (newLevel > revisionLevel) {
            long id = mConference.getSqlId();
            // Cache favorites and alerts
            List<String> favoriteGuids = mDb.getFavoriteGuids(id);
            List<Event> alerts = mDb.getAlertEvents(id);
            List<String> alertGuids = new ArrayList<String>();
            // Now cancel all of the outstanding alerts, in case
            // a talk has been moved
            AlarmManager manager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
            for (Event e : alerts) {
                alertGuids.add("\"" + e.getGuid() + "\"");
                Log.d("SUSEConferences", "Removing an alert for " + e.getTitle());

                Intent intent = new Intent(mContext, AlarmReceiver.class);
                intent.putExtras(ScheduleDetailsActivity.generateAlarmIntentBundle(mContext, e));
                PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
                        intent.getStringExtra("intentId").hashCode(), intent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                manager.cancel(pendingIntent);
                pendingIntent.cancel();
            }

            // Now clear the DB
            mDb.clearDatabase(id);
            // Download schedule
            ConferenceCacher cacher = new ConferenceCacher(new ConferenceCacherProgressListener() {
                @Override
                public void progress(String progress) {
                    publishProgress(progress);
                }
            });

            long val = cacher.cacheConference(mConference, mDb);
            mErrorMessage = cacher.getLastError();
            if (val == -1) {
                mDb.setConferenceAsCached(id, 0);
            } else {
                mDb.setLastUpdateValue(id, newLevel);
                mDb.toggleEventsInMySchedule(favoriteGuids);
                mDb.toggleEventAlerts(alertGuids);
                alerts = mDb.getAlertEvents(id);
                // ... And re-create the alerts, if they are in the future
                Date currentDate = new Date();
                for (Event e : alerts) {
                    if (currentDate.after(e.getDate()))
                        continue;
                    Log.d("SUSEConferences", "Adding an alert for " + e.getTitle());
                    alertGuids.add("\"" + e.getGuid() + "\"");
                    Intent intent = new Intent(mContext, AlarmReceiver.class);
                    intent.putExtras(ScheduleDetailsActivity.generateAlarmIntentBundle(mContext, e));
                    PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
                            intent.getStringExtra("intentId").hashCode(), intent,
                            PendingIntent.FLAG_UPDATE_CURRENT);
                    manager.set(AlarmManager.RTC_WAKEUP, e.getDate().getTime() - 300000, pendingIntent);
                }

            }
            return val;
        } else {
            return 0l;
        }
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SocketException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:com.andrew.apollo.ui.fragments.GenreFragment.java

/**
 * {@inheritDoc}// www  .  j  a v a 2  s  .c  o  m
 */
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
    mGenre = mAdapter.getItem(position);
    // Create a new bundle to transfer the artist info
    final Bundle bundle = new Bundle();
    bundle.putLong(Config.ID, Long.valueOf(mGenre.mGenreId));
    bundle.putString(Config.MIME_TYPE, MediaStore.Audio.Genres.CONTENT_TYPE);
    bundle.putString(Config.NAME, mGenre.mGenreName);

    // Create the intent to launch the profile activity
    final Intent intent = new Intent(getSherlockActivity(), ProfileActivity.class);
    intent.putExtras(bundle);
    startActivity(intent);
}

From source file:co.edu.uniajc.vtf.content.controller.PoiDetailController.java

public void navigateToRouteMap() {
    Activity loActivity = ((Activity) this.coView);
    Intent loIntent = new Intent(loActivity, NavigationActivity.class);
    Bundle loBundle = new Bundle();
    loBundle.putParcelable("destiny", this.coView.getPoiData());
    loIntent.putExtras(loBundle);
    loActivity.startActivity(loIntent);/*from   www. j av a  2s .c o m*/
}