Example usage for android.os Bundle getString

List of usage examples for android.os Bundle getString

Introduction

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

Prototype

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:it.uniroma2.foundme.studente.ShowCourseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_courses);
    context = this;
    swipeShow = (SwipeRefreshLayout) findViewById(R.id.swipe_show);
    swipeShow.setEnabled(false);//from www. j a va2  s  .  co m

    lvCorsiSeguiti = (ListView) findViewById(R.id.lvCorsiSeguiti);

    Bundle passed = getIntent().getExtras();
    Sid = passed.getString(Variables_it.ID);

    try {
        getCourse(true);
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:jp.co.conit.sss.sn.ex1.service.RegistService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    // registration_id??????SamuraiNotificationServer?registration_id???
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String registrationId = extras.getString("registration_id");
        if (!StringUtil.isEmpty(registrationId)) {
            SendSamuraiNotificationServerTask task = new SendSamuraiNotificationServerTask(
                    getApplicationContext());
            task.execute(registrationId);
        } else {/*from   w w  w  .j av a 2 s. c  o  m*/
            ResponseHandler.registedResponse();
        }
    }
    return START_NOT_STICKY;
}

From source file:com.chess.genesis.activity.GameListFrag.java

protected void sendGame(final Bundle gamedata) {
    try {/*  ww  w .j a  va  2 s  .  c o  m*/
        final String gamename = gamedata.containsKey("gameid")
                ? gamedata.getString("white") + " V. " + gamedata.getString("black")
                : gamedata.getString("name");
        final String filename = gamename + ".txt";
        final String gamestr = GameParser.export(gamedata).toString();
        final Uri uri = FileUtils.writeFile(filename, gamestr);
        final Intent intent = new Intent(Intent.ACTION_SEND);

        intent.putExtra(Intent.EXTRA_STREAM, uri);
        intent.setType("application/json");
        startActivity(intent);
    } catch (final JSONException e) {
        Toast.makeText(act, "Corrupt Game Data", Toast.LENGTH_LONG).show();
    } catch (final FileNotFoundException e) {
        Toast.makeText(act, "File Not Found", Toast.LENGTH_LONG).show();
    } catch (final IOException e) {
        Toast.makeText(act, "Error Reading File", Toast.LENGTH_LONG).show();
    }
}

From source file:fr.bmartel.android.tictactoe.gcm.MyGcmListenerService.java

/**
 * Called when message is received.//from  w  w  w.ja  v a  2s  .  c  o m
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {

    String message = data.getString("message");

    if (from.startsWith("/topics/" + GameSingleton.DEVICE_ID)) {
        Log.d(TAG, "Message: " + message);

        try {

            JSONObject object = new JSONObject(message);

            ArrayList<String> eventItem = new ArrayList<>();
            eventItem.add(object.toString());

            broadcastUpdateStringList(BroadcastFilters.EVENT_MESSAGE, eventItem);

            if (!GameSingleton.activityForeground) {

                if (object.has(RequestConstants.DEVICE_MESSAGE_TOPIC)
                        && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID)
                        && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) {

                    GameMessageTopic topic = GameMessageTopic
                            .getTopic(object.getInt(RequestConstants.DEVICE_MESSAGE_TOPIC));

                    ChallengeMessage challengeMessage = new ChallengeMessage(topic,
                            object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID),
                            object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME));

                    Log.i(TAG, "challenged by " + challengeMessage.getChallengerName() + " : "
                            + challengeMessage.getChallengerId());

                    Intent intent2 = new Intent(this, DeviceListActivity.class);
                    intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent2,
                            PendingIntent.FLAG_ONE_SHOT);
                    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Fight!")
                            .setContentText("challenged by " + challengeMessage.getChallengerName())
                            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);
                    NotificationManager notificationManager = (NotificationManager) getSystemService(
                            Context.NOTIFICATION_SERVICE);
                    notificationManager.notify(new Random().nextInt(9999), notificationBuilder.build());

                    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
                    boolean isScreenOn = pm.isScreenOn();
                    if (isScreenOn == false) {
                        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
                                | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyLock");
                        wl.acquire(10000);
                        PowerManager.WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                                "MyCpuLock");
                        wl_cpu.acquire(10000);
                    }

                    GameSingleton.pendingChallengeMessage = challengeMessage;
                    GameSingleton.pendingChallenge = true;
                }
            }

        } catch (JSONException e) {
            e.printStackTrace();

        }
    }
}

From source file:com.amanmehara.programming.android.activities.ProgramActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_programs);
    setActionBar(R.id.toolbar, true);//from   www .j  av  a2 s  .c  o  m
    recyclerView = setRecyclerView(R.id.programs_recycler_view);

    Bundle bundle = getIntent().getExtras();
    accessToken = bundle.getString("accessToken");
    languageName = bundle.getString("languageName");
    programsJson = bundle.getString("programs");
    logoBlob = bundle.getByteArray("logoBlob");

    setLanguageDatails();

    try {
        setAdapter(new JSONArray(programsJson));
    } catch (JSONException e) {
        Log.e(TAG, e.getMessage());
        setAdapter();
    }

}

From source file:com.commontime.plugin.notification.notification.AbstractClickActivity.java

/**
 * Called when local notification was clicked to launch the main intent.
 *
 * @param state/*ww w  . j  a  v a  2 s.c om*/
 *      Saved instance state
 */
@Override
public void onCreate(Bundle state) {
    super.onCreate(state);

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    Context context = getApplicationContext();

    try {
        String data = bundle.getString(Options.EXTRA);
        JSONObject options = new JSONObject(data);

        Builder builder = new Builder(context, options);

        NotificationWrapper notification = buildNotification(builder);

        onClick(notification);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:de.appplant.cordova.plugin.notification.AbstractClickActivity.java

/**
 * Called when local notification was clicked to launch the main intent.
 *
 * @param state//from www  .j  a  va2  s  .c  o m
 *      Saved instance state
 */
@Override
public void onCreate(Bundle state) {
    super.onCreate(state);

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    Context context = getApplicationContext();

    try {
        String data = bundle.getString(Options.EXTRA);
        JSONObject options = new JSONObject(data);

        Builder builder = new Builder(context, options);

        Notification notification = buildNotification(builder);

        onClick(notification);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.google.android.apps.chrometophone.AppEngineClient.java

private String getAuthToken(Context context, Account account) throws PendingAuthException {
    String authToken = null;/*  ww w .  j  a  v a  2  s.c  o  m*/
    AccountManager accountManager = AccountManager.get(context);
    try {
        AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, false, null,
                null);
        Bundle bundle = future.getResult();
        authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
        if (authToken == null) {
            throw new PendingAuthException(bundle);
        }
    } catch (OperationCanceledException e) {
        Log.w(TAG, e.getMessage());
    } catch (AuthenticatorException e) {
        Log.w(TAG, e.getMessage());
    } catch (IOException e) {
        Log.w(TAG, e.getMessage());
    }
    return authToken;
}

From source file:com.emorym.android_pusher.DeprecatedPusherSampleActivity.java

/** Called when the activity is first created. */
@Override/* w  ww  . ja va  2s.  co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.main);

    // This Handler is going to deal with incoming messages
    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Bundle bundleData = msg.getData();
            if (bundleData.getString("type").contentEquals("pusher")) {
                try {
                    JSONObject message = new JSONObject(bundleData.getString("message"));

                    Log.d("Pusher Message", message.toString());

                    Toast.makeText(mContext, message.toString(), Toast.LENGTH_SHORT).show();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    };

    mPusher = new Pusher(mHandler);
    mPusher.connect(PUSHER_APP_KEY);

    // Setup some toggles to subscribe/unsubscribe from our 2 test channels
    final ToggleButton test1 = (ToggleButton) findViewById(R.id.toggleButton1);
    final ToggleButton test2 = (ToggleButton) findViewById(R.id.toggleButton2);

    final Button send = (Button) findViewById(R.id.send_button);

    test1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (test1.isChecked())
                mPusher.subscribe(PUSHER_CHANNEL_1);
            else
                mPusher.unsubscribe(PUSHER_CHANNEL_1);
        }
    });

    test2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (test2.isChecked())
                mPusher.subscribe(PUSHER_CHANNEL_2);
            else
                mPusher.unsubscribe(PUSHER_CHANNEL_2);
        }
    });

    send.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EditText channelName = (EditText) findViewById(R.id.channel_name);
            EditText eventName = (EditText) findViewById(R.id.event_name);
            EditText eventData = (EditText) findViewById(R.id.event_data);

            try {
                JSONObject data = new JSONObject();
                data.put("data", eventData.getText().toString());
                mPusher.send(eventName.getText().toString(), data, channelName.getText().toString());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.commontime.plugin.notification.notification.AbstractTriggerReceiver.java

/**
 * Called when an alarm was triggered.//from www .  j av a2s.  c o m
 *
 * @param context
 *      Application context
 * @param intent
 *      Received intent with content data
 */
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    Options options;

    try {
        String data = bundle.getString(Options.EXTRA);
        JSONObject dict = new JSONObject(data);

        options = new Options(context).parse(dict);
    } catch (JSONException e) {
        e.printStackTrace();
        return;
    }

    if (options == null)
        return;

    if (isFirstAlarmInFuture(options))
        return;

    Builder builder = new Builder(options);
    NotificationWrapper notification = buildNotification(builder);
    boolean updated = notification.isUpdate();

    onTrigger(notification, updated);
}