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.polyvi.xface.extension.XMessagingExt.java

private void genMsgReceiveBroadcastReceive() {
    if (null == mMsgReceiveBroadcaseReveiver) {
        mMsgReceiveBroadcaseReveiver = new BroadcastReceiver() {
            @Override//from www.  j a va 2s .c  om
            public void onReceive(Context context, Intent intent) {
                if (INTENT_ACTION.equals(intent.getAction())) {
                    Bundle bundle = intent.getExtras();
                    if (null != bundle) {
                        // pdus??
                        Object[] pdus = (Object[]) bundle.get("pdus");
                        // 
                        SmsMessage[] msgs = new SmsMessage[pdus.length];
                        for (int i = 0; i < pdus.length; i++) {
                            // ???pdu?,?
                            msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                        }
                        JSONArray receivedMsgs = buildSmsList(msgs);
                        XEvent evt = XEvent.createEvent(XEventType.MSG_RECEIVED, receivedMsgs.toString());
                        XSystemEventCenter.getInstance().sendEventAsync(evt);
                    }
                }
            }
        };
    }
}

From source file:com.amazonaws.mobileconnectors.s3.transferutility.TransferService.java

/**
 * Executes command received by the service.
 *
 * @param intent received intent//from www . ja v  a2s .com
 */
void execCommand(Intent intent) {
    // update last active time
    lastActiveTime = System.currentTimeMillis();

    final String action = intent.getAction();
    final int id = intent.getIntExtra(INTENT_BUNDLE_TRANSFER_ID, 0);

    if (id == 0) {
        LOGGER.error("Invalid id: " + id);
        return;
    }

    if (INTENT_ACTION_TRANSFER_ADD.equals(action)) {
        if (updater.getTransfer(id) != null) {
            LOGGER.warn("Transfer has already been added: " + id);
        } else {
            /*
             * only add transfer when network is available or else relies on
             * the network change listener to scan the database
             */
            final TransferRecord transfer = dbUtil.getTransferById(id);
            if (transfer != null) {
                updater.addTransfer(transfer);
                transfer.start(s3, dbUtil, updater, networkInfoReceiver);
            } else {
                LOGGER.error("Can't find transfer: " + id);
            }
        }
    } else if (INTENT_ACTION_TRANSFER_PAUSE.equals(action)) {
        TransferRecord transfer = updater.getTransfer(id);
        if (transfer == null) {
            transfer = dbUtil.getTransferById(id);
        }
        if (transfer != null) {
            transfer.pause(s3, updater);
        }
    } else if (INTENT_ACTION_TRANSFER_RESUME.equals(action)) {
        TransferRecord transfer = updater.getTransfer(id);
        if (transfer == null) {
            transfer = dbUtil.getTransferById(id);
            if (transfer != null) {
                updater.addTransfer(transfer);
            } else {
                LOGGER.error("Can't find transfer: " + id);
            }
        }
        if (transfer != null) {
            transfer.start(s3, dbUtil, updater, networkInfoReceiver);
        }
    } else if (INTENT_ACTION_TRANSFER_CANCEL.equals(action)) {
        TransferRecord transfer = updater.getTransfer(id);
        if (transfer == null) {
            transfer = dbUtil.getTransferById(id);
        }
        if (transfer != null) {
            transfer.cancel(s3, updater);
        }
    } else {
        LOGGER.error("Unknown action: " + action);
    }
}

From source file:chat.client.agent.ChatClientAgent.java

private void notifySpoken(String speaker, String sentence) {
    Intent broadcast = new Intent();
    broadcast.setAction("jade.demo.chat.REFRESH_CHAT");
    broadcast.putExtra("sentence", speaker + ": " + sentence + "\n");
    logger.log(Level.INFO, "Sending broadcast " + broadcast.getAction());
    context.sendBroadcast(broadcast);/*  ww  w .j  a  v  a  2s  . c om*/
}

From source file:cn.figo.mydemo.ui.activity.VideoActivity.java

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

    mSettings = new Settings(this);

    //      handle arguments
    mVideoPath = getIntent().getStringExtra("videoPath");

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        String scheme = mVideoUri.getScheme();
        if (TextUtils.isEmpty(scheme)) {
            Log.e(TAG, "Null unknown ccheme\n");
            finish();/*w  w  w  .j a v a2  s.c  o  m*/
            return;
        }
        if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
            mVideoPath = mVideoUri.getPath();
        } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
            Log.e(TAG, "Can not resolve content below Android-ICS\n");
            finish();
            return;
        } else {
            Log.e(TAG, "Unknown scheme " + scheme + "\n");
            finish();
            return;
        }
    }

    Intent intent = getIntent();
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    new RecentMediaStorage(this).saveUrlAsync(mVideoPath);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    mVideoView.setHudView(mHudView);

    mVideoView.toggleAspectRatio();

    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }

    initDanmaku();

}

From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java

void handleIntentAPILaunch(Intent srcIntent) {
    Intent intent = new Intent(this, ImUrlActivity.class);
    intent.setAction(srcIntent.getAction());

    if (srcIntent.getData() != null)
        intent.setData(srcIntent.getData());

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (srcIntent.getExtras() != null)
        intent.putExtras(srcIntent.getExtras());
    startActivity(intent);/*from  www . j ava  2  s  . c  o m*/

    setIntent(null);
    finish();
}

From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java

private void genMsgReceiveBroadcastReceiver() {
    if (null == mMsgReceiveBroadcaseReceiver) {
        mMsgReceiveBroadcaseReceiver = new BroadcastReceiver() {
            @Override// w w  w.  ja  va 2  s  .c  o  m
            public void onReceive(Context context, Intent intent) {
                if (INTENT_ACTION.equals(intent.getAction())) {
                    Bundle bundle = intent.getExtras();
                    if (null != bundle) {
                        // pdus??
                        Object[] pdus = (Object[]) bundle.get("pdus");
                        // 
                        SmsMessage[] msgs = new SmsMessage[pdus.length];
                        for (int i = 0; i < pdus.length; i++) {
                            // ???pdu?,?
                            msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                        }
                        JSONArray receivedMsgs = buildSmsList(msgs);
                        XEvent evt = XEvent.createEvent(XEventType.MSG_RECEIVED, receivedMsgs.toString());
                        ((XFaceMainActivity) mContext).getEventCenter().sendEventAsync(evt);
                    }
                }
            }
        };
    }
}

From source file:com.hhunj.hhudata.SearchBookContentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();
    if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) {
        finish();/*w ww  .j a v  a  2s  .  com*/
        return;
    }

    //pageid,pagenumber
    //ISBN  ---stationid,
    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);//stationid
    if (isbn.startsWith("http://google.com/books?id=")) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && initialQuery.length() > 0) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:biz.bokhorst.bpt.BPTService.java

@Override
protected void onHandleIntent(Intent intent) {
    if ("Waypoint".equals(intent.getAction())) {
        once = true;//from  ww  w  .  j  a v a 2s  . c om
        waypoint = true;
        taskHandler.post(StartTask);
    } else if ("Update".equals(intent.getAction())) {
        once = true;
        taskHandler.post(StartTask);
    } else if (ActivityRecognitionResult.hasResult(intent)) {
        ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
        DetectedActivity mostProbableActivity = result.getMostProbableActivity();
        int confidence = mostProbableActivity.getConfidence();
        int activityType = mostProbableActivity.getType();

        should = (activityType != DetectedActivity.STILL);
        String activityName = getNameFromType(activityType);
        lastActivity = activityName;
        sendActivity(activityName, confidence, result.getTime());

        for (DetectedActivity activity : result.getProbableActivities())
            Log.w("BPT", TIME_FORMATTER.format(new Date(result.getTime())) + " Activity "
                    + getNameFromType(activity.getType()) + " " + activity.getConfidence() + " %");
    } else
        sendActivity(intent.getAction(), -1, new Date().getTime());
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java

/**
 * Fires notifications that have elapsed and sets an alarm to be woken at
 * the next notification./*from ww w.ja v a2 s .  com*/
 * <p/>
 * If the intent action is ACTION_DELETE, will delete the notification with
 * the indicated ID, and cancel it from any active notifications.
 */
@Override
public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())
            || Intent.ACTION_RUN.equals(intent.getAction())) {
        // Can't cancel anything. Just schedule and notify at end
    } else {
        // Always cancel
        cancelNotification(context, intent.getData());

        if (Intent.ACTION_DELETE.equals(intent.getAction()) || ACTION_RESCHEDULE.equals(intent.getAction())) {
            // Just a notification
            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .deleteOrReschedule(context, intent.getData());
        } else if (ACTION_SNOOZE.equals(intent.getAction())) {
            // msec/sec * sec/min * 30
            long delay30min = 1000 * 60 * 30;
            final Calendar now = Calendar.getInstance();

            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .setTime(context, intent.getData(), delay30min + now.getTimeInMillis());
        } else if (ACTION_COMPLETE.equals(intent.getAction())) {
            // Complete note
            Task.setCompletedSynced(context, true, intent.getLongExtra(ARG_TASKID, -1));
            // Delete notifications with the same task id
            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .removeWithTaskIdsSynced(context, intent.getLongExtra(ARG_TASKID, -1));
        }
    }

    notifyPast(context, true);
    scheduleNext(context);
}

From source file:com.dileepindia.cordova.sms.SMSPlugin.java

protected void createIncomingSMSReceiver() {
    Context ctx = this.cordova.getActivity();

    this.mReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            Log.d("SMSPlugin", "onRecieve: " + action);

            if ("android.provider.Telephony.SMS_RECEIVED".equals(action)) {
                if (SMSPlugin.this.mIntercept) {
                    abortBroadcast();/*from   w  w w  .  j a v a  2 s.c  o  m*/
                }
                Bundle bundle = intent.getExtras();
                if (bundle != null) {
                    Object[] pdus = (Object[]) bundle.get("pdus");
                    if (pdus.length != 0) {
                        for (int i = 0; i < pdus.length; i++) {
                            SmsMessage sms = SmsMessage.createFromPdu((byte[]) pdus[i]);

                            JSONObject json = SMSPlugin.this.getJsonFromSmsMessage(sms);
                            SMSPlugin.this.onSMSArrive(json);
                        }

                    }
                }
            }
        }
    };
    String[] filterstr = { "android.provider.Telephony.SMS_RECEIVED" };
    for (int i = 0; i < filterstr.length; i++) {
        IntentFilter filter = new IntentFilter(filterstr[i]);
        filter.setPriority(100);
        ctx.registerReceiver(this.mReceiver, filter);
        Log.d("SMSPlugin", "broadcast receiver registered for: " + filterstr[i]);
    }
}