Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

In this page you can find the example usage for android.os Bundle get.

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:com.mobiperf.speedometer.AccountSelector.java

private void getAuthToken(AccountManagerFuture<Bundle> result) {
    Logger.i("getAuthToken() called, result " + result);
    String errMsg = "Failed to get login cookie. ";
    Bundle bundle;
    try {/*from   w ww  .  j a v a2  s . co  m*/
        bundle = result.getResult();
        Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
        if (intent != null) {
            // User input required. (A UI will pop up for user's consent to
            // allow
            // this app access account information.)
            Logger.i("Starting account manager activity");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } else {
            Logger.i("Executing getCookie task");
            synchronized (this) {
                this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
                this.checkinFuture = checkinExecutor.submit(new GetCookieTask());
            }
        }
    } catch (OperationCanceledException e) {
        Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    } catch (AuthenticatorException e) {
        Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    } catch (IOException e) {
        Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    }
}

From source file:fr.simon.marquis.installreferrer.ReferrerReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null) {
        Log.e("ReferrerReceiver", "Intent is null");
        return;/*from  w  w w  . j a  v  a2 s.  co  m*/
    }
    if (!ACTION_INSTALL_REFERRER.equals(intent.getAction())) {
        Log.e("ReferrerReceiver",
                "Wrong action! Expected: " + ACTION_INSTALL_REFERRER + " but was: " + intent.getAction());
        return;
    }
    Bundle extras = intent.getExtras();
    if (intent.getExtras() == null) {
        Log.e("ReferrerReceiver", "No data in intent");
        return;
    }

    Application.setReferrerDate(context.getApplicationContext(), new Date().getTime());
    Application.setReferrerData(context.getApplicationContext(), (String) extras.get(KEY_REFERRER));

    LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ACTION_UPDATE_DATA));
}

From source file:com.demo.android.smsapp.receivers.SMSReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    final Bundle bundle = intent.getExtras();

    try {//  ww  w .ja  va2s  . c  o  m

        if (bundle != null) {
            NotificationManager notificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);

            final Object[] pdusObj = (Object[]) bundle.get("pdus");

            for (int i = 0; i < pdusObj.length; i++) {

                SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
                String phoneNumber = currentMessage.getDisplayOriginatingAddress();

                String message = currentMessage.getDisplayMessageBody();

                Intent chatActivityIntent = new Intent(context, SMSChatActivity.class);
                chatActivityIntent.putExtra("number", phoneNumber);
                PendingIntent pi = PendingIntent.getActivity(context, 1, chatActivityIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);

                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                        .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(phoneNumber).setContentText(message)
                        .setContentIntent(pi)
                        .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

                notificationManager.notify(99, mBuilder.build());

                Log.i("SmsReceiver", "senderNum: " + phoneNumber + "; message: " + message);

            }
        }

    } catch (Exception e) {
        Log.e("SmsReceiver", "Exception smsReceiver" + e);

    }
}

From source file:com.brodev.socialapp.view.MarketPlaceDetail.java

/** Called when the activity is first created. */
@Override//from  www. ja va2 s . co  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.market_place_content_view);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Bundle bundle = getIntent().getExtras();
    marketPlace = (MarketPlace) bundle.get("marketplace");

    phraseManager = new PhraseManager(getApplicationContext());
    user = (User) getApplicationContext();
    colorView = new ColorView(getApplicationContext());
    this.imageGetter = new ImageGetter(getApplicationContext());

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    if (marketPlace.getTime_stamp().equals("0")) {
        this.getMarketPlaceAdapter();
    }

    getSupportActionBar().setTitle(phraseManager.getPhrase(getApplicationContext(), "marketplace.marketplace"));
    initView();

    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "marketplace");
    comment.putInt("itemId", marketPlace.getListing_id());
    comment.putInt("totalComment", marketPlace.getTotal_comment());
    comment.putInt("total_like", marketPlace.getTotal_like());
    comment.putBoolean("no_share", false);
    comment.putBoolean("is_liked", marketPlace.getIs_liked());
    comment.putBoolean("can_post_comment", marketPlace.getCan_post_comment());

    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();
}

From source file:com.nagopy.android.xposed.SettingChangedReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Object obj = dataObject.get();
    if (!StringUtils.equals(intent.getAction(), action) || obj == null) {
        context.unregisterReceiver(this);
        return;//  w  ww  .j  ava2 s . c  o  m
    }

    Bundle extras = intent.getExtras();
    if (extras == null || extras.size() != 2) {
        return;
    }

    try {
        // target?value????????
        String target = extras.getString("target");
        Object value = extras.get("value");
        obj.getClass().getField(target).set(obj, value);

        onDataChanged();
    } catch (Throwable t) {
        Logger.e(getClass().getSimpleName(), Log.getStackTraceString(t));
    }
}

From source file:nuclei.task.TaskGcmService.java

@Override
public int onRunTask(TaskParams taskParams) {
    try {//from   ww  w.jav a2  s.  co m
        Bundle bundle = taskParams.getExtras();
        String taskName = bundle.getString(TaskScheduler.TASK_NAME);
        Task task = (Task) Class.forName(taskName).newInstance();
        ArrayMap<String, Object> map = new ArrayMap<>(bundle.size());
        for (String key : bundle.keySet()) {
            map.put(key, bundle.get(key));
        }
        task.deserialize(map);
        if (task.isRunning())
            return GcmNetworkManager.RESULT_RESCHEDULE;
        task.attach(null, ContextHandle.getApplicationHandle());
        task.run();
        task.deliverResult(this);
        return GcmNetworkManager.RESULT_SUCCESS;
    } catch (Exception err) {
        LOG.e("Error running task", err);
        return GcmNetworkManager.RESULT_FAILURE;
    }
}

From source file:com.billooms.harppedals.pedals.PedalFragment.java

/**
 * Restore the state of this fragment from the given savedInstanceState.
 *
 * @param bundle savedInstanceState/*from ww w.  ja va  2 s .co  m*/
 */
private void restoreInstanceState(Bundle bundle) {
    if (bundle == null) {
        return;
    }

    if (bundle.get(ARG_FIRSTNOTE) != null) {
        firstNote = new Note(bundle.getInt(ARG_FIRSTNOTE));
    }
    pedals.restoreFromBundle(bundle);
}

From source file:fr.jcf.pret.activities.PretEmpruntActivity.java

/**
 * Permet de sauvegarder des photos prises avec l'appareil photo
 * //  www.  j  a v  a 2 s . c o m
 * @param data
 * @param context
 * @param fileUri
 * @param contentResolver
 * @param imageView
 */
private void sauvegardeImage(Intent data, Context context, Uri fileUri, ContentResolver contentResolver,
        ImageView imageView) {
    Bitmap bitmap = null;
    if (data != null) {
        // L'image a t retourne (ne fonctionne pas sur certains priphriques!!!)
        Bundle extras = data.getExtras();
        bitmap = (Bitmap) extras.get("data");
        imageView.setImageBitmap(bitmap);
    } else {
        // On prpare l'image pour enregistrer son nom et son chemin en base
        Uri imageSelection = null;

        // On rcupre le nom du fichier
        String nomImage = fileUri.toString().substring(fileUri.toString().lastIndexOf("/") + 1,
                fileUri.toString().length());

        // Ici on enlve la partie "file://" afin de ne rcuprer que le chemin du rpertoire
        String chemin = fileUri.toString().substring(7, fileUri.toString().length());
        try {
            // On enregistre l'image en base pour la rcuprer plus tard
            imageSelection = Uri
                    .parse(MediaStore.Images.Media.insertImage(contentResolver, chemin, nomImage, ""));
            bitmap = UtilPret.decodeUri(imageSelection, contentResolver, imageView);

            // On associe l'image pour affichage
            imageView.setTag(imageSelection);
            imageView.setImageBitmap(bitmap);
        } catch (FileNotFoundException e) {
            Log.d(UtilPret.LOG_SOURCE, "Le fichier slectionn n'a pas t trouv.");
            Log.d(UtilPret.LOG_SOURCE, e.getMessage());
        }

    }
}

From source file:com.mobiperf.AccountSelector.java

private void getAuthToken(AccountManagerFuture<Bundle> result) {
    Logger.i("getAuthToken() called, result " + result);
    String errMsg = "Failed to get login cookie. ";
    Bundle bundle;
    try {//from  w w  w  .  j av  a 2 s.c  o m
        bundle = result.getResult();
        Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
        if (intent != null) {
            // User input required. (A UI will pop up for user's consent to allow
            // this app access account information.)
            Logger.i("Starting account manager activity");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } else {
            Logger.i("Executing getCookie task");
            synchronized (this) {
                this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
                this.checkinFuture = checkinExecutor.submit(new GetCookieTask());
            }
        }
    } catch (OperationCanceledException e) {
        Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    } catch (AuthenticatorException e) {
        Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    } catch (IOException e) {
        Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    }
}

From source file:com.num.mobiperf.AccountSelector.java

private void getAuthToken(AccountManagerFuture<Bundle> result) {
    //Logger.i("getAuthToken() called, result " + result);
    String errMsg = "Failed to get login cookie. ";
    Bundle bundle;
    try {/*  w  w w.  ja v  a  2 s . c  om*/
        bundle = result.getResult();
        Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
        if (intent != null) {
            // User input required. (A UI will pop up for user's consent to allow
            // this app access account information.)
            //Logger.i("Starting account manager activity");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } else {
            //Logger.i("Executing getCookie task");
            synchronized (this) {
                this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
                this.checkinFuture = checkinExecutor.submit(new GetCookieTask());
            }
        }
    } catch (OperationCanceledException e) {
        //Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    } catch (AuthenticatorException e) {
        //Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    } catch (IOException e) {
        //Logger.e(errMsg, e);
        throw new RuntimeException("Can't get login cookie", e);
    }
}