Example usage for android.os Bundle toString

List of usage examples for android.os Bundle toString

Introduction

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

Prototype

@Override
    public synchronized String toString() 

Source Link

Usage

From source file:fiskinfoo.no.sintef.fiskinfoo.MyPageFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null) {
        Log.d(TAG, savedInstanceState.toString());

        myPageExpandableListAdapter.onRestoreInstanceState(savedInstanceState);
        Parcelable manager = savedInstanceState.getParcelable("recycleLayout");
        LinearLayoutManager manager1 = new LinearLayoutManager(this.getActivity());
        if (manager != null) {
            mCRecyclerView.setLayoutManager(manager1);
            manager1.onRestoreInstanceState(manager);
        }//from   w ww .j a  v  a 2  s . c  om
    }

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // TODO: Will not work if token has expired, should look into fixing this in general
            boolean networkAvailable = fiskInfoUtility.isNetworkAvailable(getActivity());

            if (networkAvailable) {
                ArrayList<ParentObject> data = fetchMyPage();

                myPageExpandableListAdapter = new MyPageExpandableListAdapter(getActivity(), data,
                        childOnClickListener);
                myPageExpandableListAdapter.addExpandCollapseListener(expandCollapseListener);
                mCRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
                mCRecyclerView.setAdapter(myPageExpandableListAdapter);

                ((MainActivity) getActivity())
                        .toggleNetworkErrorTextView(fiskInfoUtility.isNetworkAvailable(getActivity()));
                mSwipeRefreshLayout.setRefreshing(false);
            } else {
                ArrayList<ParentObject> data = fetchMyPageCached();

                myPageExpandableListAdapter = new MyPageExpandableListAdapter(getActivity(), data,
                        childOnClickListener);
                myPageExpandableListAdapter.addExpandCollapseListener(expandCollapseListener);
                mCRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
                mCRecyclerView.setAdapter(myPageExpandableListAdapter);

                ((MainActivity) getActivity())
                        .toggleNetworkErrorTextView(fiskInfoUtility.isNetworkAvailable(getActivity()));
                mSwipeRefreshLayout.setRefreshing(false);
            }
        }
    });

    ((MainActivity) getActivity())
            .toggleNetworkErrorTextView(fiskInfoUtility.isNetworkAvailable(getActivity()));
}

From source file:com.downrighttech.dmxdip.MainActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    Log.v("lifeCycle", "onRestoreInstanceState-" + savedInstanceState.toString());
    //if (savedInstanceState != null){
    editText_Span.setText(savedInstanceState.get("span").toString());
    editText_Start.setText(savedInstanceState.get("start").toString());
    super.onRestoreInstanceState(savedInstanceState);
    //}/*from   w w w.  j  a  va2s.  c om*/
}

From source file:com.google.samples.apps.gcmplayground.MyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);

    registerButton = (Button) findViewById(R.id.register_button);
    unregisterButton = (Button) findViewById(R.id.unregister_button);
    stringIdentifierField = (EditText) findViewById(R.id.string_identifier);
    registrationTokenFieldView = (TextView) findViewById(R.id.registeration_token);
    statusView = (TextView) findViewById(R.id.status);
    downstreamBundleView = (TextView) findViewById(R.id.downstream_bundle);
    upstreamMessageField = (EditText) findViewById(R.id.upstream_message);
    sendButton = (Button) findViewById(R.id.button_send);
    subscribeTopicButton = (Button) findViewById(R.id.topic_subscribe);
    topicField = (EditText) findViewById(R.id.topic_name);
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);

    gcm = GoogleCloudMessaging.getInstance(this);
    pubSub = GcmPubSub.getInstance(this);

    // If Play Services is not up to date, quit the app.
    checkPlayServices();/*  ww w . jav  a2  s .  c  o m*/

    registerButton.setOnClickListener(this);
    unregisterButton.setOnClickListener(this);
    subscribeTopicButton.setOnClickListener(this);
    sendButton.setOnClickListener(this);

    // Restore from saved instance state
    if (savedInstanceState != null) {
        token = savedInstanceState.getString(RegistrationConstants.EXTRA_KEY_TOKEN, "");
        if (token != "") {
            updateUI("Registration SUCCEEDED", true);
        }
    }

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            boolean sentToken = intent.getBooleanExtra(RegistrationConstants.SENT_TOKEN_TO_SERVER, false);

            token = intent.getStringExtra(RegistrationConstants.EXTRA_KEY_TOKEN);
            if (!sentToken) {
                updateUI("Registration FAILED", false);
            }
        }
    };

    mDownstreamBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String from = intent.getStringExtra(RegistrationConstants.SENDER_ID);
            Bundle data = intent.getBundleExtra(RegistrationConstants.EXTRA_KEY_BUNDLE);
            String message = data.getString(RegistrationConstants.EXTRA_KEY_MESSAGE);

            Log.d(TAG, "Received from >" + from + "< with >" + data.toString() + "<");
            Log.d(TAG, "Message: " + message);

            String action = data.getString(RegistrationConstants.ACTION);
            String status = data.getString(RegistrationConstants.STATUS);

            if (RegistrationConstants.REGISTER_NEW_CLIENT.equals(action)
                    && RegistrationConstants.STATUS_REGISTERED.equals(status)) {
                progressBar.setVisibility(View.INVISIBLE);
                updateUI("Registration SUCCEEDED", true);
            } else if (RegistrationConstants.UNREGISTER_CLIENT.equals(action)
                    && RegistrationConstants.STATUS_UNREGISTERED.equals(status)) {
                token = "";
                updateUI("Unregistration SUCCEEDED", false);
                showToast("Unregistered!");
            } else {
                downstreamBundleView.setText(data.toString());
            }
        }
    };

    LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
            new IntentFilter(RegistrationConstants.REGISTRATION_COMPLETE));
    LocalBroadcastManager.getInstance(this).registerReceiver(mDownstreamBroadcastReceiver,
            new IntentFilter(RegistrationConstants.NEW_DOWNSTREAM_MESSAGE));

    stringIdentifierField.setText("<a_name_to_recognize_the_device>");
}

From source file:graaby.app.wallet.services.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
            sendNotification("Send error: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification("Deleted messages on server: " + extras.toString());
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            sendNotification(extras.getString(getString(R.string.field_gcm_data)));
        }/*from  w  w w . j a va 2 s  .c o m*/
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:org.roman.findme.MyGcmListenerService.java

/**
 * Called when message is received./*from   w w w  .j  a  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) {
    sharedPreferences = getSharedPreferences(RegistrationIntentService.APP_PREFERENCES, Context.MODE_PRIVATE);
    myToken = sharedPreferences.getString("my_token", null);
    mContext = this;

    String message = data.getString("message");
    assert message != null;

    Gson gson = new Gson();
    String[] response = gson.fromJson(message, String[].class);

    message = response[0];
    senderToken = response[1].replaceAll("\\s+", "");

    Log.d(TAG, data.toString());
    Log.d(TAG, message);
    Log.d(TAG, senderToken);

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    if (message.equals("c")) {
        Intent locationService = new Intent(this, LocationService.class);
        startService(locationService);
    } else {
        sendNotification(message);
    }

}

From source file:com.example.android.sunshine.app.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) {

        if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {

            String weather = extras.getString(EXTRA_WEATHER);
            String location = extras.getString(EXTRA_LOCATION);
            String alert = "Heads up: " + weather + " in " + location + "!";

            sendNotification(context, alert);

            Log.i(LOG_TAG, "Received: " + extras.toString());
        }// ww w .  j a va  2 s. co  m
    }
}

From source file:com.mobisys.android.ibp.ObservationRequestQueue.java

private void uploadImage(final boolean single, final Bundle b, final Context context,
        final ArrayList<String> imageStringPath, ArrayList<String> imageType, final ObservationInstance sp) {
    MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

    if (b != null)
        Log.d("ObservationRequestQueue", "Params: " + b.toString());
    int countUri = 0;
    for (int i = 0; i < imageStringPath.size(); i++) {
        if (!imageStringPath.get(i).contains("http://")) {
            FileBody bab;/*from w  w  w  .ja  v  a  2  s . c o  m*/
            if (imageType.get(i) != null)
                bab = new FileBody(new File(imageStringPath.get(i)), imageType.get(i)); // image path and image type
            else
                bab = new FileBody(new File(imageStringPath.get(i)), "image/jpeg"); // image p   
            reqEntity.addPart("resources", bab);

            ++countUri;
        }
    }

    // if imagestring path has no Image url's.
    if (countUri != 0) {
        try {
            reqEntity.addPart(Request.RESOURCE_TYPE, new StringBody("species.participation.Observation"));
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }

        WebService.sendMultiPartRequest(context, Request.METHOD_POST, Request.PATH_UPLOAD_RESOURCE,
                new ResponseHandler() {

                    @Override
                    public void onSuccess(String response) {
                        sp.setStatus(StatusType.PROCESSING);
                        ObservationInstanceTable.updateRowFromTable(context, sp);
                        parseUploadResourceDetail(response, single, b, context, sp, imageStringPath);
                    }

                    @Override
                    public void onFailure(Throwable e, String content) {
                        Log.d("NetWorkState", content);
                        if (e instanceof UnknownHostException || e instanceof ConnectException) {
                            mIsRunning = false;
                            return;
                        }
                        sp.setStatus(StatusType.FAILURE);
                        sp.setMessage(content);
                        ObservationInstanceTable.updateRowFromTable(context, sp);
                        //ObservationParamsTable.deleteRowFromTable(context, sp);
                        if (!single) {
                            ObservationInstance sp_new = ObservationInstanceTable.getFirstRecord(context);
                            observationMethods(single, sp_new, context);
                        }
                    }
                }, reqEntity);

    } else { // if all are url's
        for (int i = 0; i < imageStringPath.size(); i++) {
            b.putString("file_" + (i + 1), imageStringPath.get(i)
                    .replace("http://" + HttpUtils.stageOrProdBaseURL() + "/biodiv/observations/", ""));
            b.putString("type_" + (i + 1), Constants.IMAGE);
            b.putString("license_" + (i + 1), "CC_BY");
        }
        submitObservationRequestFinally(single, b, context, sp);
    }
}

From source file:com.testpush.notification.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    // The getMessageType() intent parameter must be the intent you received
    // in your BroadcastReceiver.
    String messageType = gcm.getMessageType(intent);

    Log.d("GCM", "RECEIVE");

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle

        Log.d("GCM", "RECEIVE CONTENT : " + extras.toString());

        /*// ww w  .j a v a2 s.  c  o m
         * Filter messages based on message type. Since it is likely that GCM will be
        * extended in the future with new message types, just ignore any message types you're
        * not interested in, or that you don't recognize.
        */
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
            //sendNotification("Send error: " + extras.toString(),"");
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            //sendNotification("Deleted messages on server: " + extras.toString(),"");
            // If it's a regular GCM message, do some work.
        } else {
            if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                // This loop represents the service doing some work.
                // LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
                //Criteria criteria = new Criteria();
                // String bestProvider = locationManager.getBestProvider(criteria, false);
                // Location location = locationManager.getLastKnownLocation(bestProvider);
                //  Double lat, lon;
                //}
                // Toast.makeText(GcmIntentService.this, "message", Toast.LENGHT_LONG).show();
                //  Toast mytoast=new Toast(MainActivity.this);
                //  mytoast.setView(view);
                ///  mytoast.setDuration(Toast.LENGTH_LONG);
                // mytoast.show();
                String titre = "Checking the location";// extras.getString("titre");
                String message = "the office";// extras.getString("message");}

                // if (location) {
                // lat = location.getLatitude();
                // lon = location.getLongitude();

                //titre = String.valueOf(lat);//"this is my Toast message";// extras.getString("titre");
                //message = String.valueOf(lat);//"this is my Toast message";// extras.getString("message");

                //String titre = String.valueOf(lat);//"this is my Toast message";// extras.getString("titre");
                //String message =String.valueOf(lat);//"this is my Toast message";// extras.getString("message");
                String image = extras.getString("image");
                String id = extras.getString("id");

                Intent dialogIntent = new Intent(this, MainActivity2.class);
                dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(dialogIntent);
                // startService(new Intent(this, services.class));
                //Intent intent2 = new Intent(Intent.ACTION_SEND);
                //intent2.setType("text/html");
                //intent2.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
                //intent2.putExtra(Intent.EXTRA_SUBJECT, "Subject");
                // intent2.putExtra(Intent.EXTRA_TEXT, "I'm email body.");

                //startActivity(Intent.createChooser(intent2, "Send Email"));

                //ComponentName location = new ComponentName(LocationService.getPackageName(),
                //GcmIntentService.class.getName());
                //  startService(new Intent(this, LocationService.class));
                sendNotification(titre, message, image, id);
            }
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:org.onepf.opfpush.gcm_migrate_sample.GCMIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    String messageType = BroadcastMessageListener.getMessageType(intent);
    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*/*from  w  w  w. j  a  va  2s  . co m*/
         * Filter messages based on message type. Since it is likely that GCM will be
         * extended in the future with new message types, just ignore any message types you're
         * not interested in, or that you don't recognize.
         */
        if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification("Deleted messages on server: " + extras.toString());
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // This loop represents the service doing some work.
            for (int i = 0; i < 5; i++) {
                Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime());
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException ignored) {
                }
            }
            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            sendNotification("Received: " + extras.toString());
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GCMBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.google.cloud.solutions.cloudadventure.GCMIntentService.java

/**
 * Called when a cloud message has been received.
 *//*from   w w w.  j a  va  2s.c  o  m*/
@Override
public void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

    String messageType = gcm.getMessageType(intent);

    if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
        Log.i("GCMIntentService", "Received Msg Type:" + messageType);
        Log.i("GCMIntentService", "Received Msg : " + extras.toString());

        if (PING_REASON_FRIEND_INVITE.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for friend invite.");
            Intent resultIntent = new Intent(this, ProfileActivity.class);
            resultIntent.putExtras(intent);
            generateNotification(resultIntent, ProfileActivity.class);
        } else if (PING_REASON_FRIEND_ACCEPT.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for friend acceptance.");
            Intent resultIntent = new Intent(this, ProfileActivity.class);
            resultIntent.putExtras(intent);
            generateNotification(resultIntent, ProfileActivity.class);
        } else if (PING_REASON_GAME_INVITE.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for game invite.");
            Intent resultIntent = new Intent(this, GameActivity.class);
            resultIntent.putExtras(intent);
            resultIntent.putExtra(Constants.GAME_ENTRANCE_ACTION_INTENT_EXTRA_KEY,
                    Constants.GAME_ENTRANCE_ACTION_NOTIFICATION);
            generateNotification(resultIntent, GameActivity.class);
        } else if (PING_REASON_GAME_STARTED.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for game start.");
            Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE_GAME_START);
            messageIntent.putExtras(intent);
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        } else if (PING_REASON_GAME_DESTROYED.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for game destroy.");
            Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE_GAME_DESTROY);
            messageIntent.putExtras(intent);
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        } else if (PING_REASON_GAME_ENDED.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for game end.");
            Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE_GAME_END);
            messageIntent.putExtras(intent);
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        } else if (PING_REASON_PLAYER_JOINED.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for game join.");
            Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE_PLAYER_JOIN);
            messageIntent.putExtras(intent);
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        } else if (PING_REASON_PLAYER_LEFT.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for game leave.");
            Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE_PLAYER_LEAVE);
            messageIntent.putExtras(intent);
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        } else if (PING_REASON_PLAYER_END_STATS.equals(intent.getStringExtra(GCM_PAYLOAD_PING_REASON))) {
            Log.i("GCMIntentService", "Received ping for player end stats.");
            Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE_PLAYER_END_STATS);
            messageIntent.putExtras(intent);
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        }
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}