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:sjizl.com.ChatActivityFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LayoutInflater factory = LayoutInflater.from(getActivity());
    View myView = factory.inflate(R.layout.activity_chat_fragment, null);

    if (CommonUtilities.isInternetAvailable(getActivity().getApplicationContext())) //returns true if internet available
    {//from w  w w. j ava2s. c  o  m

        SharedPreferences sp = getActivity().getApplicationContext().getSharedPreferences("loginSaved",
                Context.MODE_PRIVATE);
        pid = sp.getString("pid", null);
        naam = sp.getString("naam", null);
        username = sp.getString("username", null);
        password = sp.getString("password", null);
        foto = sp.getString("foto", null);
        foto_num = sp.getString("foto_num", null);
        Bundle bundle = getActivity().getIntent().getExtras();

        Bundle args = getArguments();

        Log.i("args", args.toString());
        if (args != null && args.containsKey("pid_user")) {

            pid_user = args.getString("pid_user");
            user = args.getString("user");
            user_foto_num = args.getString("user_foto_num");
            user_foto = args.getString("user_foto");
        } else {

            pid_user = bundle.getString("pid_user");
            user = bundle.getString("user");
            user_foto_num = bundle.getString("user_foto_num");
            user_foto = bundle.getString("user_foto");

        }
        // Toast.makeText(getApplicationContext(), "pid_user"+pid_user, Toast.LENGTH_SHORT).show();

        if (user.equalsIgnoreCase(naam.toString())) {
            Toast.makeText(getActivity().getApplicationContext(), "You can't message yourself!",
                    Toast.LENGTH_SHORT).show();
            getActivity().finish();
        }

        AbsListViewBaseActivity.imageLoader
                .init(ImageLoaderConfiguration.createDefault(getActivity().getBaseContext()));

        getActivity().registerReceiver(mHandleMessageReceiver2, new IntentFilter(DISPLAY_MESSAGE_ACTION));

        imageLoader.loadImage("https://www.sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto + "",
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                        d1 = new BitmapDrawable(getResources(), loadedImage);

                    }
                });

        imageLoader.loadImage("https://www.sjizl.com/fotos/" + foto_num + "/thumbs/" + foto + "",
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                        d2 = new BitmapDrawable(getResources(), loadedImage);

                    }
                });

        smilbtn = (ImageView) myView.findViewById(R.id.smilbtn);
        listView = (ListView) myView.findViewById(android.R.id.list);
        underlayout = (LinearLayout) myView.findViewById(R.id.underlayout);
        smiles_layout = (LinearLayout) myView.findViewById(R.id.smiles);
        textView1_bgtext = (TextView) getActivity().findViewById(R.id.textView1_bgtext);
        textView1_bgtext.setText(user);
        imageView2_dashboard = (ImageView) getActivity().findViewById(R.id.imageView2_dashboard);
        imageView1_logo = (ImageView) getActivity().findViewById(R.id.imageView1_logo);
        imageView_bericht = (ImageView) getActivity().findViewById(R.id.imageView_bericht);
        textView2_under_title = (TextView) getActivity().findViewById(R.id.textView2_under_title);
        right_lin = (LinearLayout) getActivity().findViewById(R.id.right_lin);
        left_lin1 = (LinearLayout) getActivity().findViewById(R.id.left_lin1);
        left_lin3 = (LinearLayout) getActivity().findViewById(R.id.left_lin3);
        left_lin4 = (LinearLayout) getActivity().findViewById(R.id.left_lin4);
        middle_lin = (LinearLayout) getActivity().findViewById(R.id.middle_lin);
        smile_lin = (LinearLayout) myView.findViewById(R.id.smile_lin);
        ber_lin = (LinearLayout) myView.findViewById(R.id.ber_lin);
        progressBar_hole = (ProgressBar) getActivity().findViewById(R.id.progressBar_hole);
        progressBar_hole.setVisibility(View.INVISIBLE);
        imageLoader.displayImage("http://sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto,
                imageView2_dashboard, options);
        new UpdateChat().execute();
        mNewMessage = (EditText) myView.findViewById(R.id.newmsg);
        ber_lin = (LinearLayout) myView.findViewById(R.id.ber_lin);

        /*
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    
                    
                    
            imageLoader.loadImage("http://sjizl.com/fotos/"+user_foto_num+"/thumbs/"+user_foto, new SimpleImageLoadingListener() {
               @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
        super.onLoadingComplete(imageUri, view, loadedImage);
                
        Bitmap LoadedImage2 = loadedImage;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
           if(loadedImage!=null){
        LoadedImage2 = CommonUtilities.fastblur16(loadedImage, 4,getApplicationContext());
           }
        }
                
        if (Build.VERSION.SDK_INT >= 16) {
                
           listView.setBackground(new BitmapDrawable(getApplicationContext().getResources(), LoadedImage2));
                
          } else {
                
             listView.setBackgroundDrawable(new BitmapDrawable(LoadedImage2));
          }
                
        }
        }
            );
        }
        */

        listView.setOnScrollListener(new OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                mScrollState = scrollState;
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
            }

        });
        listView.setLongClickable(true);
        registerForContextMenu(listView);

        DisplayMetrics metrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
        viewPager_smiles = new ViewPager(getActivity());
        viewPager_smiles.setId(0x1000);
        LayoutParams layoutParams555 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams555.width = LayoutParams.MATCH_PARENT;
        layoutParams555.height = (metrics.heightPixels / 2);
        viewPager_smiles.setLayoutParams(layoutParams555);
        TabsPagerAdapter mAdapter = new TabsPagerAdapter(getActivity().getSupportFragmentManager(),
                mNewMessage);
        viewPager_smiles.setAdapter(mAdapter);
        LayoutInflater inflater2 = null;
        viewPager_smiles.setVisibility(View.VISIBLE);
        smiles_layout.addView(viewPager_smiles);
        smiles_layout.setVisibility(View.GONE);

        left_lin4.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    Intent profile = new Intent(getActivity().getApplicationContext(),
                            ProfileActivityMain.class);
                    profile.putExtra("user", user);
                    profile.putExtra("user_foto", user_foto);
                    profile.putExtra("user_foto_num", user_foto_num);
                    profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(profile);
                }
                return false;
            }
        });
        middle_lin.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    Intent profile = new Intent(getActivity().getApplicationContext(),
                            ProfileActivityMain.class);
                    profile.putExtra("user", user);
                    profile.putExtra("user_foto", user_foto);
                    profile.putExtra("user_foto_num", user_foto_num);
                    profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(profile);
                }
                return false;
            }
        });

        smile_lin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                opensmiles();
            }
        });

        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent dashboard = new Intent(getActivity().getApplicationContext(), ProfileActivityMain.class);
                dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                dashboard.putExtra("user", ArrChatLines.get(position).getNaam());
                dashboard.putExtra("user_foto", foto);
                dashboard.putExtra("user_foto_num", foto_num);
                startActivity(dashboard);
            }
        });

        mNewMessage.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {

                    v.setFocusable(true);
                    v.setFocusableInTouchMode(true);

                    smiles_layout.setVisibility(View.GONE);
                    smilbtn.setImageResource(R.drawable.emoji_btn_normal);
                    return false;
                }
                return false;
            }
        });

        TextWatcher textWatcher = new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                //after text changed
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                CommonUtilities
                        .startandsendwebsock("" + pid_user + " " + naam + " " + pid + " is typing to you ...");
            }

            @Override
            public void afterTextChanged(Editable s) {
                /*
                 AsyncHttpClient.getDefaultInstance().websocket("ws://sjizl.com:9300", "my-protocol", new WebSocketConnectCallback() {
                  @Override
                     public void onCompleted(Exception ex, WebSocket webSocket) {
                         if (ex != null) {
                   ex.printStackTrace();
                   return;
                         }
                         webSocket.send(""+pid_user+" "+naam+" "+pid+" is typing to you ...");
                                 
                         webSocket.close();
                     }
                 });
                 */
            }
        };

        mNewMessage.addTextChangedListener(textWatcher);

        ber_lin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SpannableStringBuilder spanStr = (SpannableStringBuilder) mNewMessage.getText();
                Spanned cs = (Spanned) mNewMessage.getText();
                String a = Html.toHtml(spanStr);
                String text = mNewMessage.getText().toString();
                mNewMessage.setText("");
                mNewMessage.requestFocus();
                mybmp2 = "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto;
                if (text.length() < 1) {
                } else {
                    addItem(foto, foto_num, "0", naam, text.toString(),
                            "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto, "", a);
                }
            }
        });

        hideSoftKeyboard();

    } else {

        Intent dashboard = new Intent(getActivity().getApplicationContext(), NoInternetActivity.class);
        dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(dashboard);

        getActivity().finish();
    }
    mNewMessage.clearFocus();
    listView.requestFocus();

    final String wsuri = "ws://sjizl.com:9300";

    WebSocketConnection mConnection8 = new WebSocketConnection();

    if (mConnection8.isConnected()) {
        mConnection8.reconnect();

    } else {
        try {
            mConnection8.connect(wsuri, new WebSocketConnectionHandler() {

                @Override
                public void onOpen() {
                    Log.d("TAG", "Status: Connected to " + wsuri);

                }

                @Override
                public void onTextMessage(String payload) {

                    if (payload.contains("message send")) {
                        String[] parts = payload.split(" ");
                        String zender = parts[0];
                        String send_from = parts[1];
                        String send_name = parts[2];
                        String send_foto = parts[3];
                        String send_foto_num = parts[4];
                        String send_xxx = parts[5];

                        //      Toast.makeText(getApplication(), "" +   "\n zender: "+zender+"" +   "\n pid_user: "+pid_user+"" +"\n pid: "+pid+"" +
                        //         "\n send_from: "+send_from, 
                        //                  Toast.LENGTH_LONG).show();
                        if (zender.equalsIgnoreCase(pid) || zender.equalsIgnoreCase(pid_user)) {

                            if (send_from.equalsIgnoreCase(pid_user) || send_from.equalsIgnoreCase(pid)) {

                                //Toast.makeText(getApplication(), "uu",    Toast.LENGTH_LONG).show();

                                new UpdateChat().execute();

                            }
                        }

                    } else if (payload.contains("is typing to you")) {

                        String[] parts = payload.split(" ");
                        String part1 = parts[0]; // 004
                        is_typing_name = parts[1]; // 034556
                        if (is_typing_name.equalsIgnoreCase(user)) {

                            if (ArrChatLines.size() > 0) {
                                oldvalue = ArrChatLines.get(0).getLaatstOnline();

                            } else {
                                oldvalue = textView2_under_title.getText().toString();
                            }

                            Timer t = new Timer(false);
                            t.schedule(new TimerTask() {
                                @Override
                                public void run() {
                                    getActivity().runOnUiThread(new Runnable() {
                                        public void run() {
                                            textView2_under_title.setText("typing ...");
                                        }
                                    });
                                }
                            }, 2);

                            Timer t2 = new Timer(false);
                            t2.schedule(new TimerTask() {
                                @Override
                                public void run() {
                                    getActivity().runOnUiThread(new Runnable() {
                                        public void run() {
                                            textView2_under_title.setText(oldvalue);
                                        }
                                    });
                                }
                            }, 2000);
                        }

                    }
                    Log.d("TAG", "Got echo: " + payload);
                }

                @Override
                public void onClose(int code, String reason) {
                    Log.d("TAG", "Connection lost.");
                }
            });
        } catch (WebSocketException e) {
            Log.d("TAG", e.toString());
        }
    }
    return myView;

}

From source file:com.example.gcm_client_test.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);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//from  www. j a  v a  2s.com
         * 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());
            // Do nothing
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            // sendNotification("Deleted messages on server: "
            // + extras.toString());
            // Do nothing

        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // If it's a regular GCM message, do some work.
            /*
             * @@@ REGULAR GCM MESSAGE HANDLER
             */
            // Post notification of received message.
            sendNotification(extras);
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.consumer.gcm.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);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*/* w w  w  .j a  v a 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_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.

            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());

            // Post notification of received message.
            sendNotification(extras);
            Log.i(TAG, "Received: " + extras.toString());

        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.nobledesignlabs.lookupaddress.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);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//from   w w w  .ja va  2  s  . c om
         * 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)) {
            // displayNotification(this,"Send error: " + extras);
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            // displayNotification(this,"Deleted messages on server: "
            // + extras);
            // 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.
            // Post notification of received message.
            displayNotification(this, extras);
            Log.i(CommonStuff.TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.firescar96.nom.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);

    if (!extras.isEmpty())
        /*/*from   w ww  . j ava  2 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))
            Log.i(Consts.TAG, "onHandleIntent: message error");
        else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType))
            Log.i(Consts.TAG, "onHandleIntent: message deleted");
        // If it's a regular GCM message, do some work.
        else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // Post notification of received message.
            System.out.println("Received: " + extras.toString());

            if (context == null) {
                System.out.println("null conxtext");
                /*Intent needIntent = new Intent(this, MainActivity.class);
                 needIntent.putExtra("purpose", "update");
                 needIntent.putExtra("mate", (String)extras.get("mate"));
                 needIntent.putExtra("event", (String)extras.get("event"));
                 needIntent.putExtra("chat", (String)extras.get("chat"));
                 needIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 startActivity(needIntent);*/
                System.out.println(getFilesDir().getAbsolutePath());
                MainActivity.initAppData(getFilesDir().getAbsolutePath());
            }

            try {
                if (extras.get("mate") != null) {
                    //context.appData.getJSONArray("mates").put(extras.get("mate"));
                }

                if (extras.get("event") != null) {
                    JSONObject eveData = new JSONObject("{\"event\":" + extras.get("event") + "}")
                            .getJSONObject("event");
                    JSONArray eve = MainActivity.appData.getJSONArray("events");
                    for (int i = 0; i < eve.length(); i++) {
                        System.out.println(eveData.getString("hash"));
                        System.out.println(eve.getJSONObject(i).getString("hash"));
                        if (eveData.getString("hash").equals(eve.getJSONObject(i).getString("hash")))
                            return;
                    }
                    eveData.accumulate("member", false);
                    System.out.println(eveData.getLong("date"));
                    System.out.println(Calendar.getInstance().getTimeInMillis());
                    if (eveData.getLong("date") < Calendar.getInstance().getTimeInMillis())
                        return;

                    eve.put(eveData);
                    Message msg = new Message();
                    Bundle data = new Bundle();
                    data.putString("type", "event." + eveData.getString("privacy"));
                    data.putString("host", eveData.getString("host"));
                    data.putString("date", eveData.getString("date"));
                    msg.setData(data);
                    contextHandler.sendMessage(msg);
                }

                if (extras.get("chat") != null) {
                    JSONObject chatData = new JSONObject("{\"chat\":" + extras.get("chat") + "}")
                            .getJSONObject("chat");
                    JSONArray eve = MainActivity.appData.getJSONArray("events");
                    for (int i = 0; i < eve.length(); i++)
                        if (chatData.getString("hash").equals(eve.getJSONObject(i).getString("hash"))) {
                            JSONObject msgSon = new JSONObject();
                            msgSon.accumulate("author", chatData.getString("author"));
                            msgSon.accumulate("message", chatData.getString("message"));
                            eve.getJSONObject(i).getJSONArray("chat").put(msgSon);

                            Message msg = new Message();
                            Bundle data = new Bundle();
                            data.putString("type", "chat");
                            data.putString("author", chatData.getString("author"));
                            data.putString("message", chatData.getString("message"));
                            data.putBoolean("member", eve.getJSONObject(i).getBoolean("member"));
                            data.putString("hash", chatData.getString("hash"));
                            msg.setData(data);
                            contextHandler.sendMessage(msg);

                            return;
                        }
                }

                MainActivity.closeAppData(getFilesDir().getAbsolutePath());
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
        }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    MainBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.app.ntuc.notifs.MyGcmListenerService.java

/**
 * Called when message is received.//from   www. j  a va2 s .c om
 *
 * @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) {
    Bundle bodyBundle = data.getBundle("notification");
    String body = bodyBundle.getString("body");

    String title = bodyBundle.getString("title");
    Log.e("----", body + " " + title);
    //        String alert = data.getString("alert");
    //dhlWPSZjJO4:APA91bGPdpNkFzcneN6Ge82LorApbFPHdga6mfYZh-rzjb_SBBGlAppjiz5wAPELv05nCoYC2BAOX0Mxw3GwBUkQnHP7ejkvc1oW77RDJ0VKAYZdv4hD-xS9lfSek79S3ZMcX8-jw_wc
    //        String title = data.getString("title");
    //        Log.d(TAG, "From: " + from);
    //        Log.d(TAG, "Content Staff: " + data.toString());
    //        if (from.startsWith("/topics/")) {
    //            // message received from some topic.
    //        } else {
    //            // normal downstream message.
    //        }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */

    //        if(title.equals("Comment Notification"))
    //        {
    //            Gson gson=new Gson();
    //            MessageCommendReponse message=gson.fromJson(data.getString("custom"), MessageCommendReponse.class);
    //            sendBroadCastCommandNotification(message);
    //
    //        }
    //        sendNotification(body,title,data);
    sendNotifications(body);
    Log.v("Notification", data.toString());

    // [END_EXCLUDE]
}

From source file:com.moxtra.moxiechat.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);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // Post notification of received message.
            boolean handled = MXNotificationManager.preProcessMXNotification(getApplicationContext(), intent);
            if (handled) {
                // This is a moxtra message and it will be handled by moxtra
                if (intent.getBooleanExtra(MXNotificationManager.MOXTRA_MESSAGE_SHOW_NOTIFICATION, false)) {
                    String title = intent.getStringExtra(MXNotificationManager.MOXTRA_MESSAGE_TITLE_TEXT);
                    if (intent.hasExtra(MXNotificationManager.MOXTRA_MESSAGE_ALERT_SOUND)) {
                        String soundUrl = intent
                                .getStringExtra(MXNotificationManager.MOXTRA_MESSAGE_ALERT_SOUND);
                        Log.d(TAG, "soundUrl = " + soundUrl);
                        Uri uri = Uri.parse(soundUrl);
                        sendMoxtraNotification(title, uri, intent);
                    } else {
                        sendMoxtraNotification(title, intent);
                    }//from  ww w.j a  v  a 2s  .com
                }
            } else {
                // Not a moxtra message and app should handle it.
                Log.i(TAG, "App should handle it.");
            }
            Log.i(TAG, "Received: " + extras.toString());
        }
    }

    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.qurater.pivotal.gcm.GcmIntentServiceV2.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);

    if (extras != null && !extras.isEmpty()) { // has effect of unparcelling Bundle
        /*/*from  www  . j a  va 2s . 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.
            /*
            for (int i = 0; i < 5; i++) {
            Log.i(TAG, "Working... " + (i + 1)
                    + "/5 @ " + SystemClock.elapsedRealtime());
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
            }
            }*/
            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            sendNotification(extras);
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.tessoft.nearhere.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);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*/*w  w w  .  j a va2  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(extras);
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification(extras);
            // 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 e) {
            }
             }
             Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
             // Post notification of received message.
                     
             */

            sendNotification(extras);
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.dattasmoon.pebble.plugin.EditNotificationActivity.java

public void save() {
    String selectedPackages = "";
    ArrayList<String> tmpArray = new ArrayList<String>();
    if (lvPackages == null || lvPackages.getAdapter() == null) {
        return;/*  ww w  .j  a v  a  2  s . co m*/
    }
    for (String strPackage : ((packageAdapter) lvPackages.getAdapter()).selected) {
        if (!strPackage.isEmpty()) {
            if (!tmpArray.contains(strPackage)) {
                tmpArray.add(strPackage);
                selectedPackages += strPackage + ",";
            }
        }
    }
    tmpArray.clear();
    tmpArray = null;
    if (!selectedPackages.isEmpty()) {
        selectedPackages = selectedPackages.substring(0, selectedPackages.length() - 1);
    }
    if (Constants.IS_LOGGABLE) {
        switch (mMode) {
        case OFF:
            Log.i(Constants.LOG_TAG, "Mode is: off");
            break;
        case EXCLUDE:
            Log.i(Constants.LOG_TAG, "Mode is: exclude");
            break;
        case INCLUDE:
            Log.i(Constants.LOG_TAG, "Mode is: include");
            break;
        }

        Log.i(Constants.LOG_TAG, "Package list is: " + selectedPackages);
    }

    if (mode == Mode.STANDARD) {

        Editor editor = sharedPreferences.edit();
        editor.putInt(Constants.PREFERENCE_MODE, mMode.ordinal());
        editor.putString(Constants.PREFERENCE_PACKAGE_LIST, selectedPackages);
        editor.putString(Constants.PREFERENCE_PKG_RENAMES, arrayRenames.toString());

        // we saved via the application, reset the variable if it exists
        editor.remove(Constants.PREFERENCE_TASKER_SET);

        // clear out legacy preference, if it exists
        editor.remove(Constants.PREFERENCE_EXCLUDE_MODE);

        // save!
        editor.commit();

        // notify service via file that it needs to reload the preferences
        File watchFile = new File(getFilesDir() + "PrefsChanged.none");
        if (!watchFile.exists()) {
            try {
                watchFile.createNewFile();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        watchFile.setLastModified(System.currentTimeMillis());
    } else if (mode == Mode.LOCALE) {
        if (!isCanceled()) {
            final Intent resultIntent = new Intent();
            final Bundle resultBundle = new Bundle();

            // set the version, title and body
            resultBundle.putInt(Constants.BUNDLE_EXTRA_INT_VERSION_CODE,
                    Constants.getVersionCode(getApplicationContext()));
            resultBundle.putInt(Constants.BUNDLE_EXTRA_INT_TYPE, Constants.Type.SETTINGS.ordinal());
            resultBundle.putInt(Constants.BUNDLE_EXTRA_INT_MODE, mMode.ordinal());
            resultBundle.putString(Constants.BUNDLE_EXTRA_STRING_PACKAGE_LIST, selectedPackages);
            resultBundle.putString(Constants.BUNDLE_EXTRA_STRING_PKG_RENAMES, arrayRenames.toString());
            String blurb = "";
            switch (mMode) {
            case OFF:
                blurb = getResources().getStringArray(R.array.mode_choices)[0];
                break;
            case INCLUDE:
                blurb = getResources().getStringArray(R.array.mode_choices)[2];
                break;
            case EXCLUDE:
                blurb = getResources().getStringArray(R.array.mode_choices)[1];
            }
            Log.i(Constants.LOG_TAG, resultBundle.toString());

            resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, resultBundle);
            resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);
            setResult(RESULT_OK, resultIntent);
        }
    }

}