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:be.brunoparmentier.wifikeyshare.ui.activities.WifiNetworkActivity.java

void initializeNfcStateChangeListener() {
    nfcStateChangeBroadcastReceiver = new BroadcastReceiver() {
        @Override/*from w  w w.java2  s . co  m*/
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();

            if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) {
                final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF);

                switch (state) {
                case NfcAdapter.STATE_OFF:
                case NfcAdapter.STATE_TURNING_OFF:
                    onNfcDisabled();
                    break;
                case NfcAdapter.STATE_TURNING_ON:
                    break;
                case NfcAdapter.STATE_ON:
                    onNfcEnabled();
                    break;
                }
            }
        }
    };
}

From source file:com.perm.DoomPlay.PlayingService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    String action = intent.getAction();

    assert action != null;

    if (action.equals(actionOffline) || action.equals(actionOnline)) {
        isOnline = action.equals(actionOnline);

        audios = intent.getParcelableArrayListExtra(FullPlaybackActivity.keyService);

        if (intent.getIntExtra(FullPlaybackActivity.keyIndex, 0) != valueIncredible)
            indexCurrentTrack = intent.getIntExtra(FullPlaybackActivity.keyIndex, 0);

        loadMusic();/*w  w w .  jav  a2s .  c  om*/
    } else
        handleNotifControll(action);

    return START_NOT_STICKY;
}

From source file:com.example.mynsocial.BluetoothChat.java

NdefMessage[] getNdefMessages(Intent intent) {
    Log.e(TAG, "+++ getNdefMessages +++");
    NdefMessage[] msgs = null;//from w w  w .  jav  a 2  s  . c  o  m
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        if (rawMsgs != null) {
            msgs = new NdefMessage[rawMsgs.length];
            for (int i = 0; i < rawMsgs.length; i++) {
                msgs[i] = (NdefMessage) rawMsgs[i];
            }
        } else {
            byte[] empty = new byte[] {};
            NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty);
            NdefMessage msg = new NdefMessage(new NdefRecord[] { record });
            msgs = new NdefMessage[] { msg };
        }
    } else {
        Log.d("Peer to Peer 2", "Unknown intent.");
        finish();
    }

    return msgs;
}

From source file:com.notalenthack.blaster.CommandActivity.java

private void setupFilter() {
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Constants.ACTION_REFRESH_STATUS);
    mReceiver = new BroadcastReceiver() {
        @Override//w  w  w.jav a2  s.  com
        public void onReceive(Context context, Intent intent) {
            // Got intent to clean up
            if (intent.getAction().equals(Constants.ACTION_REFRESH_STATUS)) {
                if (D)
                    Log.d(TAG, "onReceive intent " + intent.toString());
                List<Command> commands = mListAdapter.getCommands();
                // this list should be in the same order as in the ListBox
                int i = 0;
                for (Command cmd : commands) {
                    if (cmd.getDisplayStatus()) {
                        mSerialService.sendStatusCommand(cmd.getCommandStat(), i, false);
                    }
                    i++;
                }
            }
        }
    };
    registerReceiver(mReceiver, filter);
}

From source file:com.jacr.instagramtrendreader.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_main);

    /* Customizing ActionBar */
    Resources r = getResources();
    ActionBar ab = super.getActionBar(false);
    ab.setIcon(r.getDrawable(R.drawable.ic_menu_home));
    ab.setTitle(Util.getTitleActivity(getString(R.string.title_my_gallery_app)));

    /* Views *//*from   w w  w .j a v  a2s .c o m*/
    layoutThumbnail = (TableLayout) findViewById(R.id.layoutThumbnail);
    layoutThumbnail.setPadding(1, 1, 1, 1);

    /* Setting Viewpager and Indicator */
    mPager = (ViewPager) findViewById(R.id.pagerMain);
    mAdapter = new ViewPagerAdapter<MainFragment>(getSupportFragmentManager());
    mPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int arg0) {
            int key = feedReader.getListThumbnailKeys().get(arg0);
            feedReader.highlightThumbnail(key);

        }

    });

    /* Receiver */
    mReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            Bundle extras = intent.getExtras();
            if (action.contentEquals(ACTION_IMAGE_CLICK)) {
                int key = extras.getInt(ACTION_IMAGE_CLICK);
                if (key != -1) {
                    Intent in = new Intent(Main.this, ImageDetails.class);
                    Bundle b = new Bundle();

                    /*
                     * Warning with Error FAILED BINDED TRANSACTION: it
                     * happens When the transfer of "extras" out of memory.
                     * in This case, when images are sent in intent.
                     */
                    b.putSerializable(ImageDetails.KEY_THUMBNAIL_DATA, feedReader.getListThumbnailData());
                    b.putSerializable(ImageDetails.KEY_THUMBNAIL_KEYS, feedReader.getListThumbnailKeys());
                    b.putInt(ImageDetails.KEY_THUMBNAIL_ACTUAL_KEY, key);
                    in.putExtras(b);
                    startActivity(in);
                }

            }
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_IMAGE_CLICK);
    registerReceiver(mReceiver, filter);

    /* Load data from Instagram */
    cargarFeedReader();
}

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

@Override
public void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();//from   ww  w. ja  v a 2 s.c  o m
    if (extras != null) {
        String url = (String) extras.get("url");
        String title = (String) extras.get("title");
        String sel = (String) extras.get("sel");
        String debug = (String) extras.get("debug");

        if (debug != null) {
            // server-controlled debug - the server wants to know
            // we received the message, and when. This is not user-controllable,
            // we don't want extra traffic on the server or phone. Server may
            // turn this on for a small percentage of requests or for users
            // who report issues.
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet get = new HttpGet(AppEngineClient.BASE_URL + "/debug?id=" + extras.get("collapse_key"));
            // No auth - the purpose is only to generate a log/confirm delivery
            // (to avoid overhead of getting the token)
            try {
                client.execute(get);
            } catch (ClientProtocolException e) {
                // ignore
            } catch (IOException e) {
                // ignore
            }
        }

        if (title != null && url != null && url.startsWith("http")) {
            SharedPreferences settings = Prefs.get(context);
            Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel);

            // Notify and optionally start activity
            if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) {
                LauncherUtils.playNotificationSound(context);
                LauncherUtils.sendIntentToApp(context, launchIntent);
            } else {
                LauncherUtils.generateNotification(context, url, title, launchIntent);
            }

            // Record history (for link/maps only)
            if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) {
                HistoryDatabase.get(context).insertHistory(title, url);
            }
        }
    }
}

From source file:com.nadmm.airports.tfr.TfrService.java

private void getTfrList(Intent intent) {
    boolean force = intent.getBooleanExtra(FORCE_REFRESH, false);

    File tfrFile = getFile(TFR_CACHE_NAME);
    if (!tfrFile.exists() || force) {
        URI uri;//w  ww. ja  va2  s  .  c  o m
        try {
            uri = URIUtils.createURI("http", TFR_HOST, 80, TFR_PATH, TFR_QUERY, null);
            fetch(uri, tfrFile);
        } catch (URISyntaxException e) {
            UiUtils.showToast(this, "TFR: " + e.getMessage());
        }
    }

    TfrList tfrList = new TfrList();
    mParser.parse(tfrFile, tfrList);
    Collections.sort(tfrList.entries);

    Intent result = makeResultIntent(intent.getAction());
    result.putExtra(TFR_LIST, tfrList);
    sendResultIntent(result);
}

From source file:org.exoplatform.shareextension.ShareActivity.java

private boolean isIntentCorrect() {
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    mMultiFlag = Intent.ACTION_SEND_MULTIPLE.equals(action);
    return ((Intent.ACTION_SEND.equals(action) || mMultiFlag) && type != null);
}

From source file:android.support.v7.media.MediaRouteProviderService.java

@Override
public IBinder onBind(Intent intent) {
    if (intent.getAction().equals(SERVICE_INTERFACE)) {
        if (mProvider == null) {
            MediaRouteProvider provider = onCreateMediaRouteProvider();
            if (provider != null) {
                String providerPackage = provider.getMetadata().getPackageName();
                if (!providerPackage.equals(getPackageName())) {
                    throw new IllegalStateException("onCreateMediaRouteProvider() returned "
                            + "a provider whose package name does not match the package "
                            + "name of the service.  A media route provider service can "
                            + "only export its own media route providers.  " + "Provider package name: "
                            + providerPackage + ".  Service package name: " + getPackageName() + ".");
                }/*from   ww  w  .  j  a  va2  s .  com*/
                mProvider = provider;
                mProvider.setCallback(mProviderCallback);
            }
        }
        if (mProvider != null) {
            return mReceiveMessenger.getBinder();
        }
    }
    return null;
}

From source file:org.span.manager.MainActivity.java

/** Called when the activity is first created. */
@Override/* ww  w. j  a  v a2  s. c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate()"); // DEBUG

    setContentView(R.layout.main);

    app = (ManetManagerApp) getApplication();
    app.manet.registerObserver(this);

    // init table rows
    startTblRow = (TableRow) findViewById(R.id.startAdhocRow);
    stopTblRow = (TableRow) findViewById(R.id.stopAdhocRow);
    radioModeImage = (ImageView) findViewById(R.id.radioModeImage);
    batteryTemperatureLayout = (RelativeLayout) findViewById(R.id.layoutBatteryTemp);
    headerMainLayout = (RelativeLayout) findViewById(R.id.layoutHeaderMain);

    batteryTemperature = (TextView) findViewById(R.id.batteryTempText);
    tvIP = (TextView) findViewById(R.id.tvIP);
    tvSSID = (TextView) findViewById(R.id.tvSSID);

    // Update the IP and SSID display immediate when the Activity is shown and
    // when the orientation is changed.
    app.manet.sendManetConfigQuery();

    // define animation
    animation = new ScaleAnimation(0.9f, 1, 0.9f, 1, // From x, to x, from y, to y
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(600);
    animation.setFillAfter(true);
    animation.setStartOffset(0);
    animation.setRepeatCount(1);
    animation.setRepeatMode(Animation.REVERSE);

    // start button
    startBtn = (ImageView) findViewById(R.id.startAdhocBtn);
    startBtnListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, "StartBtn pressed ...");
            showDialog(ID_DIALOG_STARTING);
            currDialogId = ID_DIALOG_STARTING;
            app.manet.sendStartAdhocCommand();
        }
    };
    startBtn.setOnClickListener(this.startBtnListener);

    // stop button
    stopBtn = (ImageView) findViewById(R.id.stopAdhocBtn);
    stopBtnListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, "StopBtn pressed ...");
            showDialog(ID_DIALOG_STOPPING);
            currDialogId = ID_DIALOG_STOPPING;
            app.manet.sendStopAdhocCommand();
        }
    };
    stopBtn.setOnClickListener(this.stopBtnListener);

    // start messenger service so that it runs even if no active activities are bound to it
    startService(new Intent(this, MessageService.class));
    Intent theIntent = getIntent();
    String action = theIntent.getAction();

    String intentData = theIntent.getDataString();
    if (action != null && action.equals(Intent.ACTION_VIEW)) {
        Bundle bundle = new Bundle(1);
        bundle.putString("filepath", intentData);
        showDialog(ID_DIALOG_CONFIG, bundle);
    }

    EulaHelper eula = new EulaHelper(this, this);
    eula.showDialog();
}