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.google.android.DemoKit.DemoKitActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    String action = intent.getAction();
    if (action.equals(UsbManager.ACTION_USB_ACCESSORY_ATTACHED)) {
        try {//from  ww w. j  a va 2s  .  c  o  m
            mAccessoryController.send(Message.obtain(null, UsbMessages.ACCESSORY_ATTACHED, 0, 0));
        } catch (RemoteException e) {
        }
        ;
    }

}

From source file:me.piebridge.prevent.framework.SystemReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (MANAGER_ACTIONS.contains(action)) {
        handleManager(context, intent, action);
    } else if (PACKAGE_ACTIONS.contains(action)) {
        handlePackage(intent, action);/*from   w  w w. j  av  a  2  s  . c om*/
    } else if (NON_SCHEME_ACTIONS.contains(action)) {
        handleNonScheme(action);
    }
}

From source file:air.com.snagfilms.cast.chromecast.notifications.VideoCastNotificationService.java

@Override
public void onCreate() {
    super.onCreate();
    Log.d(TAG, "onCreate()");
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    mBroadcastReceiver = new BroadcastReceiver() {

        @Override/*from  www .  j  a va 2 s. c  om*/
        public void onReceive(Context context, Intent intent) {
            Log.d(TAG, "onReceive(): " + intent.getAction());
        }
    };

    registerReceiver(mBroadcastReceiver, filter);

    readPersistedData();
    mCastManager = VideoChromeCastManager.initialize(this, mApplicationId, mTargetActivity, null);
    if (!mCastManager.isConnected()) {
        mCastManager.reconnectSessionIfPossible(this, false);
    }
    mConsumer = new VideoCastConsumerImpl() {
        @Override
        public void onApplicationDisconnected(int errorCode) {
            Log.d(TAG, "onApplicationDisconnected() was reached");
            stopSelf();
        }

        @Override
        public void onRemoteMediaPlayerStatusUpdated() {
            int mediaStatus = mCastManager.getPlaybackStatus();
            VideoCastNotificationService.this.onRemoteMediaPlayerStatusUpdated(mediaStatus);
        }

    };
    mCastManager.addVideoCastConsumer(mConsumer);
}

From source file:com.sanfriend.launcher4.InstallShortcutReceiver.java

public void onReceive(Context context, Intent data) {
    if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) {
        return;//from  ww w. j  a v  a  2  s .  c  om
    }

    PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, context);
    if (info.launchIntent == null || info.label == null) {
        if (DBG)
            Log.e(TAG, "Invalid install shortcut intent");
        return;
    }

    info = convertToLauncherActivityIfPossible(info);
    queuePendingShortcutInfo(info, context);
}

From source file:com.google.codelabs.appauth.MainActivity.java

private void checkIntent(@Nullable Intent intent) {
    if (intent != null) {
        String action = intent.getAction();
        switch (action) {
        case "com.google.codelabs.appauth.HANDLE_AUTHORIZATION_RESPONSE":
            if (!intent.hasExtra(USED_INTENT)) {
                handleAuthorizationResponse(intent);
                intent.putExtra(USED_INTENT, true);
            }/*from   ww w. j  a va2 s  .  co  m*/
            break;
        default:
            // do nothing
        }
    }
}

From source file:bander.notepad.NoteEditAppCompat.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Setting the theme

    Notepad.setAppCompatThemeFromPreferences(this, "Edit");

    if (savedInstanceState != null) {
        final Object note = savedInstanceState.get(ORIGINAL_NOTE);
        if (note != null)
            mOriginalNote = (Note) note;
    }/*from   w  ww . ja  v a 2s.c o m*/

    final Intent intent = getIntent();
    final String action = intent.getAction();
    if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action)) {
        mState = STATE_EDIT;
        mUri = intent.getData();
    } else if (Intent.ACTION_INSERT.equals(action)) {
        mState = STATE_INSERT;
        if (mOriginalNote == null) {
            mUri = getContentResolver().insert(intent.getData(), null);
        } else {
            mUri = mOriginalNote.getUri();
        }

        setResult(RESULT_OK, (new Intent()).setAction(mUri.toString()));
    }

    if (mUri == null) {
        finish();
        return;
    }

    {
        setContentView(R.layout.edit_appcompat);
        SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this);

        ViewStub stub = (ViewStub) findViewById(R.id.toolbarWrapper);
        if (mSettings.getBoolean("darkAppCompatTheme", false))
            stub.setLayoutResource(R.layout.toolbar_dark);
        else
            stub.setLayoutResource(R.layout.toolbar_light);
        stub.inflate();
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        Notepad.setToolbarColor(this);
        setSupportActionBar(toolbar);

        if (mSettings.getBoolean("darkAppCompatTheme", false)) {
            toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        } else {
            toolbar.setNavigationIcon(
                    IconTintFactory.setDarkMaterialColor(R.drawable.abc_ic_ab_back_mtrl_am_alpha, this));
        }

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mBodyText = (EditText) findViewById(R.id.body);

    }

}

From source file:net.oschina.app.ui.MainActivity.java

/**
 * ??intent/*from  www  . j  av  a2  s . c om*/
 * 
 * @author ?? 2015-1-28 ?3:48:44
 * 
 * @return void
 * @param intent
 */
private void handleIntent(Intent intent) {
    if (intent == null)
        return;
    String action = intent.getAction();
    if (action != null && action.equals(Intent.ACTION_VIEW)) {
        UIHelper.showUrlRedirect(this, intent.getDataString());
    } else if (intent.getBooleanExtra("NOTICE", false)) {
        notifitcationBarClick(intent);
    }
}

From source file:name.gumartinm.weather.information.fragment.overview.OverviewFragment.java

@Override
public void onResume() {
    super.onResume();

    this.mReceiver = new BroadcastReceiver() {

        @Override// w ww .  jav  a 2 s.  c o m
        public void onReceive(final Context context, final Intent intent) {
            final String action = intent.getAction();
            if (action.equals(BROADCAST_INTENT_ACTION)) {
                final Forecast forecastRemote = (Forecast) intent.getSerializableExtra("forecast");

                // 1. Check conditions. They must be the same as the ones that triggered the AsyncTask.
                final DatabaseQueries query = new DatabaseQueries(context.getApplicationContext());
                final WeatherLocation weatherLocation = query.queryDataBase();
                final PermanentStorage store = new PermanentStorage(context.getApplicationContext());
                final Forecast forecast = store.getForecast();

                if (forecast == null
                        || !OverviewFragment.this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {

                    if (forecastRemote != null) {
                        // 2. Update UI.
                        OverviewFragment.this.updateUI(forecastRemote);

                        // 3. Update Data.
                        store.saveForecast(forecastRemote);
                        weatherLocation.setLastForecastUIUpdate(new Date());
                        query.updateDataBase(weatherLocation);

                        // 4. Show list.
                        OverviewFragment.this.setListShownNoAnimation(true);
                    } else {
                        // Empty list and show error message (see setEmptyText in onCreate)
                        OverviewFragment.this.setListAdapter(null);
                        OverviewFragment.this.setListShownNoAnimation(true);
                    }
                }
            }
        }
    };

    // Register receiver
    final IntentFilter filter = new IntentFilter();
    filter.addAction(BROADCAST_INTENT_ACTION);
    LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext())
            .registerReceiver(this.mReceiver, filter);

    final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext());
    final WeatherLocation weatherLocation = query.queryDataBase();
    if (weatherLocation == null) {
        // Nothing to do.
        // Empty list and show error message (see setEmptyText in onCreate)
        this.setListAdapter(null);
        this.setListShownNoAnimation(true);
        return;
    }

    final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
    final Forecast forecast = store.getForecast();

    if (forecast != null && this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {
        this.updateUI(forecast);
    } else {
        // Load remote data (aynchronous)
        // Gets the data from the web.
        this.setListShownNoAnimation(false);
        final OverviewTask task = new OverviewTask(this.getActivity().getApplicationContext(),
                new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))),
                new ServiceForecastParser(new JPOSForecastParser()));

        task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude());
    }
}

From source file:ch.kanti_baden.pu_marc_14b.traffictimewaste.SORT_TYPE.java

private void setupRecyclerViewAsync(@NonNull final ViewGroup viewGroup) {
    final ProgressDialog progressDialog = ProgressDialog.show(this,
            getResources().getString(R.string.progress_loading_posts),
            getResources().getString(R.string.progress_please_wait), true, false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    DatabaseLink.DatabaseListener listener = new DatabaseLink.DatabaseListener() {
        @Override//  w  w  w  .j a  va 2  s.  co  m
        void onGetResponse(String str) {
            final Post[] posts;
            try {
                JSONObject json = new JSONObject(str);
                posts = DatabaseLink.parseJson(json);
            } catch (JSONException e) {
                onError("JSON is invalid. Error: " + e.getMessage() + ", JSON: " + str);
                return;
            }

            if (progressDialog.isShowing())
                progressDialog.dismiss();

            final Post[] sortedPosts = sortPosts(posts);

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    // Inflate layout post_list
                    View rootView = View.inflate(PostListActivity.this, R.layout.post_list, null);
                    RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.post_list);

                    // Setup refresh action
                    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) rootView
                            .findViewById(R.id.swipe_refresh);
                    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                        @Override
                        public void onRefresh() {
                            recreate();
                        }
                    });

                    // Set adapter with posts
                    recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(sortedPosts));

                    // Add to ViewGroup
                    viewGroup.addView(rootView);
                }
            });
        }

        @Override
        void onError(String error) {
            if (progressDialog.isShowing())
                progressDialog.dismiss();

            new AlertDialog.Builder(progressDialog.getContext()).setTitle("Error").setMessage(error).show();
        }
    };

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction()))
        DatabaseLink.instance.getPostsWithTag(listener, intent.getStringExtra(SearchManager.QUERY));
    else
        DatabaseLink.instance.getAllPosts(listener);
    Log.v("TrafficTimeWaste", "Querying db...");
}

From source file:com.khoahuy.phototag.HomeActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mCurrentPhotoPath = savedInstanceState.getString("mCurrentPhotoPath");
    Intent intent = getIntent();
    if (intent != null && Intent.EXTRA_UID.equals(intent.getAction())) {
        setIntent(null);/* www.  j  av a 2s .c  o  m*/
    }

}