Example usage for android.content Intent getAction

List of usage examples for android.content Intent getAction

Introduction

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

Prototype

public @Nullable String getAction() 

Source Link

Document

Retrieve the general action to be performed, such as #ACTION_VIEW .

Usage

From source file:com.piusvelte.sonet.core.PhotoUploadService.java

private void start(Intent intent) {
    if (intent != null) {
        String action = intent.getAction();
        if (Sonet.ACTION_UPLOAD.equals(action)) {
            if (intent.hasExtra(Accounts.TOKEN) && intent.hasExtra(Statuses.MESSAGE)
                    && intent.hasExtra(Widgets.INSTANT_UPLOAD)) {
                String place = null;
                if (intent.hasExtra(Splace))
                    place = intent.getStringExtra(Splace);
                String tags = null;
                if (intent.hasExtra(Stags))
                    tags = intent.getStringExtra(Stags);
                // upload a photo
                Notification notification = new Notification(R.drawable.notification, "uploading photo",
                        System.currentTimeMillis());
                notification.setLatestEventInfo(getBaseContext(), "photo upload", "uploading",
                        PendingIntent.getActivity(PhotoUploadService.this, 0,
                                (Sonet.getPackageIntent(PhotoUploadService.this, About.class)), 0));
                ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID,
                        notification);/*from  w w  w  . j  a v  a2 s .  co m*/
                (new AsyncTask<String, Void, String>() {

                    @Override
                    protected String doInBackground(String... params) {
                        String response = null;
                        if (params.length > 2) {
                            Log.d(TAG, "upload file: " + params[2]);
                            HttpPost httpPost = new HttpPost(String.format(FACEBOOK_PHOTOS, FACEBOOK_BASE_URL,
                                    Saccess_token, mSonetCrypto.Decrypt(params[0])));
                            MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
                            File file = new File(params[2]);
                            ContentBody fileBody = new FileBody(file);
                            entity.addPart(Ssource, fileBody);
                            HttpClient httpClient = SonetHttpClient
                                    .getThreadSafeClient(getApplicationContext());
                            try {
                                entity.addPart(Smessage, new StringBody(params[1]));
                                if (params[3] != null)
                                    entity.addPart(Splace, new StringBody(params[3]));
                                if (params[4] != null)
                                    entity.addPart(Stags, new StringBody(params[4]));
                                httpPost.setEntity(entity);
                                response = SonetHttpClient.httpResponse(httpClient, httpPost);
                            } catch (UnsupportedEncodingException e) {
                                Log.e(TAG, e.toString());
                            }
                        }
                        return response;
                    }

                    @Override
                    protected void onPostExecute(String response) {
                        // notify photo success
                        String message = getString(response != null ? R.string.success : R.string.failure);
                        Notification notification = new Notification(R.drawable.notification,
                                "photo upload " + message, System.currentTimeMillis());
                        notification.setLatestEventInfo(getBaseContext(), "photo upload", message,
                                PendingIntent.getActivity(PhotoUploadService.this, 0,
                                        (Sonet.getPackageIntent(PhotoUploadService.this, About.class)), 0));
                        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID,
                                notification);
                        stopSelfResult(mStartId);
                    }

                }).execute(intent.getStringExtra(Accounts.TOKEN), intent.getStringExtra(Statuses.MESSAGE),
                        intent.getStringExtra(Widgets.INSTANT_UPLOAD), place, tags);
            }
        }
    }
}

From source file:com.shafiq.myfeedle.core.PhotoUploadService.java

private void start(Intent intent) {
    if (intent != null) {
        String action = intent.getAction();
        if (Myfeedle.ACTION_UPLOAD.equals(action)) {
            if (intent.hasExtra(Accounts.TOKEN) && intent.hasExtra(Statuses.MESSAGE)
                    && intent.hasExtra(Widgets.INSTANT_UPLOAD)) {
                String place = null;
                if (intent.hasExtra(Splace))
                    place = intent.getStringExtra(Splace);
                String tags = null;
                if (intent.hasExtra(Stags))
                    tags = intent.getStringExtra(Stags);
                // upload a photo
                Notification notification = new Notification(R.drawable.notification, "uploading photo",
                        System.currentTimeMillis());
                notification.setLatestEventInfo(getBaseContext(), "photo upload", "uploading",
                        PendingIntent.getActivity(PhotoUploadService.this, 0,
                                (Myfeedle.getPackageIntent(PhotoUploadService.this, About.class)), 0));
                ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID,
                        notification);/*from w ww.  ja  v a  2s  .c  o  m*/
                (new AsyncTask<String, Void, String>() {

                    @Override
                    protected String doInBackground(String... params) {
                        String response = null;
                        if (params.length > 2) {
                            Log.d(TAG, "upload file: " + params[2]);
                            HttpPost httpPost = new HttpPost(String.format(FACEBOOK_PHOTOS, FACEBOOK_BASE_URL,
                                    Saccess_token, mMyfeedleCrypto.Decrypt(params[0])));
                            MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
                            File file = new File(params[2]);
                            ContentBody fileBody = new FileBody(file);
                            entity.addPart(Ssource, fileBody);
                            HttpClient httpClient = MyfeedleHttpClient
                                    .getThreadSafeClient(getApplicationContext());
                            try {
                                entity.addPart(Smessage, new StringBody(params[1]));
                                if (params[3] != null)
                                    entity.addPart(Splace, new StringBody(params[3]));
                                if (params[4] != null)
                                    entity.addPart(Stags, new StringBody(params[4]));
                                httpPost.setEntity(entity);
                                response = MyfeedleHttpClient.httpResponse(httpClient, httpPost);
                            } catch (UnsupportedEncodingException e) {
                                Log.e(TAG, e.toString());
                            }
                        }
                        return response;
                    }

                    @Override
                    protected void onPostExecute(String response) {
                        // notify photo success
                        String message = getString(response != null ? R.string.success : R.string.failure);
                        Notification notification = new Notification(R.drawable.notification,
                                "photo upload " + message, System.currentTimeMillis());
                        notification.setLatestEventInfo(getBaseContext(), "photo upload", message,
                                PendingIntent.getActivity(PhotoUploadService.this, 0,
                                        (Myfeedle.getPackageIntent(PhotoUploadService.this, About.class)), 0));
                        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID,
                                notification);
                        stopSelfResult(mStartId);
                    }

                }).execute(intent.getStringExtra(Accounts.TOKEN), intent.getStringExtra(Statuses.MESSAGE),
                        intent.getStringExtra(Widgets.INSTANT_UPLOAD), place, tags);
            }
        }
    }
}

From source file:com.dimasdanz.kendalipintu.NFCOpenDoorActivity.java

private void handleIntent(Intent intent) {
    String action = intent.getAction();
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
        String type = intent.getType();
        if (MIME_TEXT_PLAIN.equals(type)) {
            Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
            if (SharedPreferencesManager.getLoggedInPrefs(getApplicationContext())) {
                new NdefReaderTask().execute(tag);
            } else {
                Intent i = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(i);/*w ww.  j  av  a  2 s . com*/
            }
        } else {
            Log.d(TAG, "Wrong mime type: " + type);
        }
    }
}

From source file:es.udc.fic.android.robot_control.robot.ConectorPlaca.java

public void conectar(Context ctx, Intent intent) throws TransmisionErrorException {

    Log.i(C.ROBOT_TAG, "Conectando a [ " + intent.getAction() + " ]. modo - Host");
    device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
    Log.i(C.ROBOT_TAG, "Conectando a [ " + device.getDeviceName() + " ]. modo - Host");
    /* Get the USB manager from the requesting context */
    this.manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE);
    conectar();//from   w  w w. j  a  va2 s.co m
}

From source file:com.winsuk.pebbletype.WatchCommunication.java

@Override
public void onReceive(Context context, Intent intent) {
    if (ACTION_PEBBLE_RECEIVE.equals(intent.getAction())) {
        final UUID receivedUuid = (UUID) intent.getSerializableExtra("uuid");

        // Pebble-enabled apps are expected to be good citizens and only inspect broadcasts containing their UUID
        if (!PEBBLE_APP_UUID.equals(receivedUuid)) {
            return;
        }// w w w .j  av  a 2  s .  co  m

        final int transactionId = intent.getIntExtra("transaction_id", -1);
        final String jsonData = intent.getStringExtra("msg_data");
        if (jsonData == null || jsonData.isEmpty()) {
            return;
        }

        try {
            final PebbleDictionary data = PebbleDictionary.fromJson(jsonData);
            receiveData(context, transactionId, data);
        } catch (JSONException e) {
            e.printStackTrace();
            return;
        }
    }

    if (ACTION_SMS_REPLY.equals(intent.getAction())) {
        boolean sent = getResultCode() == Activity.RESULT_OK;

        if (!sent)
            Log.w("com.winsuk.pebbletype", "Message failed to send. Result code: " + getResultCode());

        PebbleDictionary data = new PebbleDictionary();
        data.addUint8(sent ? KEY_MESSAGE_SENT : KEY_MESSAGE_NOT_SENT, (byte) 1);
        PebbleKit.sendDataToPebble(context, PEBBLE_APP_UUID, data);
    }
}

From source file:com.sonetel.plugins.sonetelcallback.CallBack.java

@Override
public void onReceive(final Context context, Intent intent) {
    if (SipManager.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) {
        // Retrieve and cache infos from the phone app 
        if (!sPhoneAppInfoLoaded) {
            Resources r = context.getResources();
            BitmapDrawable drawable = (BitmapDrawable) r.getDrawable(R.drawable.ic_wizard_sonetel);
            sPhoneAppBmp = drawable.getBitmap();

            sPhoneAppInfoLoaded = true;/*from www.  ja v a2s  .c om*/
        }

        Bundle results = getResultExtras(true);
        //if(pendingIntent != null) {
        //   results.putParcelable(CallHandlerPlugin.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent);
        //}
        results.putString(Intent.EXTRA_TITLE, "Call back");// context.getResources().getString(R.string.use_pstn));
        if (sPhoneAppBmp != null) {
            results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, sPhoneAppBmp);
        }
        if (intent.getStringExtra(Intent.EXTRA_TEXT) == null)
            return;

        final String dialledNum = intent.getStringExtra(Intent.EXTRA_TEXT);
        final String callthrunum = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        DBAdapter dbAdapt = new DBAdapter(context);

        // Build pending intent

        SipAccount = dbAdapt.getAccount(1);

        if (SipAccount != null) {

            //Intent i = new Intent(Intent.ACTION_CALL);
            //i.setData(Uri.fromParts("tel", callthrunum, null));
            //final PendingIntent pendingIntent  = PendingIntent.getActivity(context, 0, i,  PendingIntent.FLAG_CANCEL_CURRENT);

            NetWorkThread = new Thread() {
                public void run() {
                    SendMsgToNetWork(dialledNum, callthrunum, context, null);
                };
            };

            NetWorkThread.start();

        } else if (SipAccount.acc_id != "1")
            Toast.makeText(context, "Unable to find Sonetel account. Please sign in using your Sonetel account",
                    Toast.LENGTH_LONG).show();

        if (!dialledNum.equalsIgnoreCase("")) {
            SipCallSessionImpl callInfo = new SipCallSessionImpl();

            callInfo.setRemoteContact(dialledNum);
            callInfo.setIncoming(false);
            callInfo.callStart = System.currentTimeMillis();
            callInfo.setAccId(4);
            //callInfo.setLastStatusCode(pjsua.PJ_SUCCESS);

            ContentValues cv = CallLogHelper.logValuesForCall(context, callInfo, callInfo.callStart);
            context.getContentResolver().insert(SipManager.CALLLOG_URI, cv);

        }
        //}
        //else
        //{

        //}
    }

    // This will exclude next time tel:xxx is raised from csipsimple treatment which is wanted
    //results.putString(Intent.EXTRA_PHONE_NUMBER, callthrunum);

}

From source file:com.geekandroid.sdk.sample.JPushReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();/*from ww w  . j  av a  2 s .  co m*/
    Log.d(TAG, "[JPushReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));

    if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
        String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
        Log.d(TAG, "[JPushReceiver] Registration Id : " + regId);
        //send the Registration Id to your server...

    } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] ???: "
                + bundle.getString(JPushInterface.EXTRA_MESSAGE));
        processCustomMessage(context, bundle);

    } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] ??");
        int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
        Log.d(TAG, "[JPushReceiver] ??ID: " + notifactionId);

    } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] ");
        JPushImpl.getInstance().clearAllNotifications();

        //Activity
        Intent i = new Intent(context, JPushOpenActivity.class);
        i.putExtras(bundle);
        //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(i);

    } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] RICH PUSH CALLBACK: "
                + bundle.getString(JPushInterface.EXTRA_EXTRA));
        //? JPushInterface.EXTRA_EXTRA ??Activity ..

    } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
        boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
        Log.w(TAG, "[JPushReceiver]" + intent.getAction() + " connected state change to " + connected);
    } else {
        Log.d(TAG, "[JPushReceiver] Unhandled intent - " + intent.getAction());
    }
}

From source file:edu.mit.media.realityanalysis.fieldtest.MainPipeline.java

@Override
protected void onHandleIntent(Intent intent) {
    if (ACTION_RUN_ONCE.equals(intent.getAction())) {
        String probeName = intent.getStringExtra(RUN_ONCE_PROBE_NAME);
        runProbeOnceNow(probeName);/*from ww w . j  a v  a2 s .c o m*/
    } else if (ACTION_UPLOAD_DATA.equals(intent.getAction())) {
        uploadData();
    } else {
        super.onHandleIntent(intent);
    }
}

From source file:ca.uwaterloo.magic.goodhikes.GPSLoggingService.java

private void onHandleIntent(Intent intent) {
    if (intent.getAction().equals(GPSTrackingCommands.START)) {
        startLocationTrackingInLooperThread();
    } else if (intent.getAction().equals(GPSTrackingCommands.STOP)) {
        stopLocationTrackingInLooperThread();
    }//from ww w .  j ava 2 s . c  om

}

From source file:com.bakhtiyor.android.tumblr.TumblrService.java

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);
    Bundle extras = intent.getExtras();/*from   w  w w. j a  va2s .c om*/
    if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null)) {
        if (extras.containsKey(KEY_EMAIL) && extras.containsKey(KEY_PASSWORD) && extras.containsKey(KEY_CAPTION)
                && extras.containsKey(KEY_IS_PRIVATE) && extras.containsKey(KEY_FILENAME)) {
            String email = extras.getString(KEY_EMAIL);
            String password = extras.getString(KEY_PASSWORD);
            String caption = extras.getString(KEY_CAPTION);
            boolean isPrivate = extras.getBoolean(KEY_IS_PRIVATE);
            String filename = extras.getString(KEY_FILENAME);
            uploadPhoto(email, password, caption, isPrivate, filename);
        }
    }
    stopSelf(startId);
}