Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

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

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:com.data.pack.ViewVideo.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.videoplay);//from ww w .j  a v  a2s . c o  m
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    filename = extras.getString("workoutname");
    workoutID = extras.getString("workoutID");
    UserName = extras.getString("UserName");
    userID = extras.getString("userID");
    // l= (View)findViewById(R.id.btnnavigation);
    btnQuit = (Button) findViewById(R.id.headeQuitricon);
    // btnplay =(Button)findViewById(R.id.btnplay);
    placeData = new PlaceDataSQL(this);
    GlobalData.appcount++;
    if (arrVoVideoName == null)
        arrVoVideoName = new ArrayList<VOWorkoutVideos>();
    GlobalData.viewvideochange = 0;
    if (videoPathes == null)
        videoPathes = new ArrayList<Object>();

    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON;

    // params.screenBrightness = 10;
    getWindow().setAttributes(params);
    if (obUser.getSelectedLanguage().equals("1")) {
        YesString = "Yes";
        strLeaveVideo = "You are about to exit the Video. Are you sure ?";
        NoString = "No";
    } else {
        YesString = "Ja";
        QuitString = "verlassen";
        strLeaveVideo = "Du bist dabei das Video zu beenden, bist Du sicher ?";
        NoString = "Nein";
    }
    count = 1;
    // Toast.makeText(getBaseContext(), "countcountcountcount"
    // +count,Toast.LENGTH_LONG).show();
    // btnQuit =(Button) findViewById(R.id.headeQuitricon);
    btnQuit.setText(QuitString);
    btnQuit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // Intent intent = new Intent(sharescreen.this,
            // HomeScreen.class);
            // // intent.putExtra("userID", userID);
            // startActivity(intent);

            AlertDialog alertDialog = new AlertDialog.Builder(ViewVideo.this).create();
            if (mVideoView.isPlaying()) {
                mVideoView.pause();
            }

            alertDialog.setTitle("fitness4.me");
            alertDialog.setMessage(strLeaveVideo);

            alertDialog.setButton(-1, YesString, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        GlobalData.viewvideochange = 1;
                        Intent intent = new Intent(ViewVideo.this, FitnessforMeActivity.class);
                        startActivity(intent);
                        if (mVideoView != null)
                            mVideoView.stopPlayback();

                    } catch (Exception e) {
                        // TODO: handle exception
                    }
                }
            });
            alertDialog.setButton(-2, NoString, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    GlobalData.viewvideochange = 0;

                    mVideoView.start();

                    dialog.cancel();
                }
            });
            try {
                alertDialog.show();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    });
    mycontroller = new MediaController(this);
    mVideoView = (VideoView) findViewById(R.id.surface_view);
    mVideoView.setMediaController(null);
    AdView adView = (AdView) this.findViewById(R.id.adView);
    if (GlobalData.allPurchased == true) {

        adView.setVisibility(View.GONE);
    } else {
        adView.setVisibility(View.VISIBLE);
        adView.loadAd(new AdRequest());

    }

    try {
        myTimer = new Timer();
        myTimer.schedule(new TimerTask() {

            @Override
            public void run() {
                TimerMethod();
            }

        }, 1, 1000);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    mVideoView.setOnCompletionListener(myVideoViewCompletionListener);
    getDataAndPopulate();

}

From source file:com.achep.acdisplay.iab.utils.IabHelper.java

int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras().get(RESPONSE_CODE);
    if (o == null) {
        logError("Intent with no response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return (Integer) o;
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {/* w  w  w  . ja  v a 2s .c o  m*/
        logError("Unexpected type for intent response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}

From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java

/**
 * Called from FindActivity.onActivityResult(). Used to 
 * update the Find's View, specifically the date, lat, long,
 * and alarm icon fields./*from  w w w .jav  a 2 s.c om*/
 * 
 * @param context, the calling Activity
 * @param find, the current Find
 * @param view, the FindActivity's content view
 * @param intent, the Intent that is passed to the menu activity
 */
public void onActivityResultCallback(Context context, Find find, View view, Intent intent) {
    Log.i(TAG, "onActivityResultCallbac");
    // Intent is NOT null, meaning it includes reminder
    // date and location information set by the user
    if (intent != null) {
        Bundle bundle = intent.getExtras();

        // Get date, longitude, and latitude
        String date = bundle.getString(Find.TIME);
        Double longitude = bundle.getDouble(Find.LONGITUDE);
        Double latitude = bundle.getDouble(Find.LATITUDE);

        TextView tv = (TextView) view.findViewById(R.id.isAdhocTextView);

        Integer is_adhoc = bundle.getInt(Find.IS_ADHOC);
        Log.i(TAG, "is_adhoc = " + is_adhoc);
        if (tv != null) {
            Log.i(TAG, "Setting isAdhocTextView to " + is_adhoc);
            tv.setText("" + is_adhoc);
        }

        // Display user specified longitude and latitude
        tv = (TextView) view.findViewById(R.id.longitudeValueTextView);
        tv.setText(String.valueOf(longitude));
        tv = (TextView) view.findViewById(R.id.latitudeValueTextView);
        tv.setText(String.valueOf(latitude));

        // Remove the old row that displays time and replace it
        // with a new row that include an alarm clock icon to
        // visually indicate this find has a reminder attached
        ViewGroup parent = (ViewGroup) view.findViewById(R.id.timeValueTextView).getParent();
        parent.removeAllViews();
        ImageView alarmIcon = new ImageView(context);
        alarmIcon.setImageResource(R.drawable.reminder_alarm);
        TableRow.LayoutParams lp1 = new TableRow.LayoutParams(30, 30);
        lp1.setMargins(0, 6, 80, 0);
        parent.addView(alarmIcon, lp1);
        TextView mCloneTimeTV = new TextView(context);
        mCloneTimeTV.setId(R.id.timeValueTextView);
        mCloneTimeTV.setText(date);
        mCloneTimeTV.setTextSize(12);
        TextView mTimeTV = (TextView) view.findViewById(R.id.timeValueTextView);
        mTimeTV = mCloneTimeTV;
        TableRow.LayoutParams lp2 = new TableRow.LayoutParams();
        lp2.setMargins(6, 6, 0, 0);
        parent.addView(mTimeTV, lp2);
    }
}

From source file:com.mikecorrigan.bohrium.pubsub.RegistrationClient.java

private void c2dmHandleRegistrationResponse(final Context context, Intent intent) {
    Log.d(TAG, "c2dmHandleRegistrationResponse: context=" + context + ", intent=" + intent + ", extras="
            + Utils.bundleToString(intent.getExtras()));

    final String registrationId = intent.getStringExtra(EXTRA_REGISTRATION_ID);
    String error = intent.getStringExtra(EXTRA_ERROR);
    String unregistered = intent.getStringExtra(EXTRA_UNREGISTERED);

    Log.d(TAG, "handleRegistration: registrationId = " + registrationId + ", error = " + error
            + ", unregistered = " + unregistered);

    mConfiguration.putLong(LAST_CHANGE, System.currentTimeMillis());

    if (unregistered != null) {
        // Unregistered
        mConfiguration.putString(REG_ID, "");
        setStateAndNotify(REGISTRATION_STATE_UNREGISTERING, REGISTRATION_SUBSTATE_NONE);

        mHandler.sendEmptyMessage(EVENT_UNREGISTER_COMPLETE);
    } else if (error != null) {
        // Registration failed.
        Log.e(TAG, "Registration error " + error);

        mConfiguration.putString(REG_ID, "");
        setStateAndNotify(REGISTRATION_STATE_ERROR, error);

        if ("SERVICE_NOT_AVAILABLE".equals(error)) {
            long backoffTime = mConfiguration.getLong(C2DM_BACKOFF, DEFAULT_BACKOFF);

            // For this error, try again later.
            Log.d(TAG, "Scheduling registration retry, backoff = " + backoffTime);
            Intent retryIntent = new Intent(C2DM_INTENT_RETRY);
            PendingIntent retryPIntent = PendingIntent.getBroadcast(context, 0 /* requestCode */, retryIntent,
                    0 /* flags */);

            AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
            am.set(AlarmManager.ELAPSED_REALTIME, backoffTime, retryPIntent);

            // Next retry should wait longer.
            backoffTime *= BACKOFF_MULTIPLIER;
            if (backoffTime > MAX_BACKOFF) {
                backoffTime = MAX_BACKOFF;

                mConfiguration.putLong(C2DM_BACKOFF, backoffTime);
            }/*from   ww w.j  ava  2 s  .  co m*/

            // Save the backoff time.
            writePreferences();
        }
    } else {
        mConfiguration.putString(REG_ID, registrationId);
        setStateAndNotify(REGISTRATION_STATE_REGISTERING, REGISTRATION_SUBSTATE_HAVE_REG_ID);

        mHandler.sendEmptyMessage(EVENT_REGISTER_COMPLETE);
    }
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java

/**
 *
 * Called when response is received from the server for authentication request. See
 * onAuthenticationResult(). Sets the AccountAuthenticatorResult which is sent back to the
 * caller. Also sets the authToken in AccountManager for this account.
 *
 * @param userData//from w  ww  . jav  a 2s  .  co m
 *            TODO
 * @param the
 *            confirmCredentials result.
 */

protected void finishLogin(Bundle userData) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "finishLogin()");
    }

    final Account account = createAccount(mUsername);

    if (mRequestNewAccount) {
        mAccountManager.addAccountExplicitly(account, mPassword, userData);
        // Automatically enable sync for this account
        ContentResolver.setSyncAutomatically(account, getAuthority(), true);
    } else {
        mAccountManager.setPassword(account, mPassword);
    }
    final Intent intent = new Intent();
    mAuthtoken = mPassword;
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, getAccountType());
    if (mAuthtokenType != null && mAuthtokenType.equals(getAuthtokenType())) {
        intent.putExtra(AccountManager.KEY_AUTHTOKEN, mAuthtoken);
    }
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}

From source file:eu.masconsult.bgbanking.accounts.AccountAuthenticator.java

@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
        Bundle options) throws NetworkErrorException {
    Log.v(TAG, "getAuthToken(account: " + account + ", authTokenType: " + authTokenType + ")");

    Bank bank = Bank.fromAccountType(context, account.type);
    if (bank == null) {
        throw new IllegalArgumentException("unsupported account type " + account.type);
    }//  w w w.  j  a  va2  s .  c o  m
    if (!Constants.getAuthorityType(context).equals(authTokenType)) {
        throw new IllegalArgumentException("unsupported authTOkenType " + authTokenType);
    }

    final Intent intent = new Intent(context, LoginActivity.class);
    intent.putExtra(KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    intent.putExtra(KEY_ACCOUNT_NAME, account.name);
    intent.putExtra(KEY_ACCOUNT_TYPE, account.type);

    String password = accountManager.getPassword(account);
    try {
        String authToken = bank.getClient().authenticate(account.name, password);
        Log.v(TAG, "obtained auth token " + authToken);

        if (authToken == null) {
            throw new AuthenticationException("no authToken");
        }

        // store the new auth token and return it
        accountManager.setAuthToken(account, authTokenType, authToken);
        intent.putExtra(KEY_AUTHTOKEN, authToken);
        return intent.getExtras();
    } catch (ParseException e) {
        Log.w(TAG, "ParseException", e);
        Bundle bundle = new Bundle();
        bundle.putInt(KEY_ERROR_CODE, 1);
        bundle.putString(KEY_ERROR_MESSAGE, e.getMessage());
        return bundle;
    } catch (IOException e) {
        Log.w(TAG, "IOException", e);
        throw new NetworkErrorException(e);
    } catch (CaptchaException e) {
        Log.w(TAG, "CaptchaException", e);
        // We need human to verify captcha
        final Bundle bundle = new Bundle();
        bundle.putParcelable(AccountManager.KEY_INTENT, intent);
        intent.putExtra(KEY_CAPTCHA_URI, e.getCaptchaUri());
        return bundle;
    } catch (AuthenticationException e) {
        Log.w(TAG, "AuthenticationException", e);
        // we need new credentials
        final Bundle bundle = new Bundle();
        bundle.putParcelable(AccountManager.KEY_INTENT, intent);
        return bundle;
    }
}

From source file:com.deange.marathonapp.billing.IabHelper.java

int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras().get(RESPONSE_CODE);
    if (o == null) {
        logError("Intent with no response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return (Integer) o;
    else if (o instanceof Long)
        return ((Long) o).intValue();
    else {//  w  w  w. j a  va  2 s.c  om
        logError("Unexpected type for intent response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}

From source file:com.google.ytd.SubmitActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.submit);

    this.authorizer = new GlsAuthorizer.GlsAuthorizerFactory().getAuthorizer(this,
            GlsAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE);

    dbHelper = new DbHelper(this);
    dbHelper = dbHelper.open();/*from w  w w.ja v  a2s .c  om*/

    Intent intent = this.getIntent();
    this.videoUri = intent.getData();
    this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN);
    this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID);
    this.title = intent.getExtras().getString(DbHelper.DESCRIPTION);
    this.instructions = intent.getExtras().getString(DbHelper.INSTRUCTIONS);

    this.domainHeader = (TextView) this.findViewById(R.id.domainHeader);
    domainHeader.setText(SettingActivity.getYtdDomains(this).get(this.ytdDomain));

    this.preferences = this.getSharedPreferences(MainActivity.SHARED_PREF_NAME, Activity.MODE_PRIVATE);
    this.youTubeName = preferences.getString(DbHelper.YT_ACCOUNT, null);

    final Button submitButton = (Button) findViewById(R.id.submitButton);
    submitButton.setEnabled(false);

    submitButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_LEGAL);
        }
    });

    Button cancelButton = (Button) findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    EditText titleEdit = (EditText) findViewById(R.id.submitTitle);
    titleEdit.setText(title);
    titleEdit.setEnabled(false);
    enableSubmitIfReady();

    EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription);
    descriptionEdit.setText(instructions);
    descriptionEdit.setEnabled(false);

    Cursor cursor = this.managedQuery(this.videoUri, null, null, null, null);

    if (cursor.getCount() == 0) {
        Log.d(LOG_TAG, "not a valid video uri");
        Toast.makeText(SubmitActivity.this, "not a valid video uri", Toast.LENGTH_LONG).show();
    } else {
        getVideoLocation();

        if (cursor.moveToFirst()) {

            long id = cursor.getLong(cursor.getColumnIndex(Video.VideoColumns._ID));
            this.dateTaken = new Date(cursor.getLong(cursor.getColumnIndex(Video.VideoColumns.DATE_TAKEN)));

            SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm aaa");
            Configuration userConfig = new Configuration();
            Settings.System.getConfiguration(getContentResolver(), userConfig);
            Calendar cal = Calendar.getInstance(userConfig.locale);
            TimeZone tz = cal.getTimeZone();

            dateFormat.setTimeZone(tz);

            TextView dateTakenView = (TextView) findViewById(R.id.dateCaptured);
            dateTakenView.setText("Date captured: " + dateFormat.format(dateTaken));

            ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail);
            ContentResolver crThumb = getContentResolver();
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 1;
            Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id,
                    MediaStore.Video.Thumbnails.MICRO_KIND, options);
            thumbnail.setImageBitmap(curThumb);
        }
    }
}

From source file:com.archer.circle_run.util.IabHelper.java

int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras() != null ? i.getExtras().get(RESPONSE_CODE) : null;
    if (o == null) {
        logError("Intent with no response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {//w  w  w .j ava  2s . com
        logError("Unexpected type for intent response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}

From source file:com.andersson.minesweeper.util.IabHelper.java

private int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras().get(RESPONSE_CODE);
    if (o == null) {
        logError("Intent with no response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {/*from  ww  w  .  ja v a 2s .  c  o m*/
        logError("Unexpected type for intent response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}