Example usage for android.content Intent hasExtra

List of usage examples for android.content Intent hasExtra

Introduction

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

Prototype

public boolean hasExtra(String name) 

Source Link

Document

Returns true if an extra value is associated with the given name.

Usage

From source file:io.v.syncslides.DeckChooserFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CODE_IMPORT_DECK:
        if (resultCode != Activity.RESULT_OK) {
            String errorStr = data != null && data.hasExtra(DocumentsContract.EXTRA_ERROR)
                    ? data.getStringExtra(DocumentsContract.EXTRA_ERROR)
                    : "";
            toast("Error selecting deck to import " + errorStr);
            break;
        }/*w  w w  . j  a v a  2 s. c o  m*/
        Uri uri = data.getData();
        DeckImporter importer = new DeckImporter(getActivity().getContentResolver(), DB.Singleton.get());
        ListenableFuture<Void> future = importer.importDeck(DocumentFile.fromTreeUri(getContext(), uri));
        Futures.addCallback(future, new FutureCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                toast("Import complete");
            }

            @Override
            public void onFailure(Throwable t) {
                toast("Import failed: " + t.getMessage());
            }
        });
        break;
    }
}

From source file:com.audiokernel.euphonyrmt.library.SimpleLibraryActivity.java

private Fragment getRootFragment() {
    final Intent intent = getIntent();
    final Fragment rootFragment;

    if (intent.hasExtra(EXTRA_ALBUM)) {
        final Album album = intent.getParcelableExtra(EXTRA_ALBUM);

        rootFragment = new SongsFragment().init(album);
    } else if (intent.hasExtra(EXTRA_ARTIST)) {
        final Artist artist = intent.getParcelableExtra(EXTRA_ARTIST);
        final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mApp);

        if (settings.getBoolean(LibraryFragment.PREFERENCE_ALBUM_LIBRARY, true)) {
            rootFragment = new AlbumsGridFragment(artist);
        } else {//from   www  .java 2  s.  c o  m
            rootFragment = new AlbumsFragment(artist);
        }
    } else if (intent.hasExtra(EXTRA_FOLDER)) {
        final String folder = intent.getStringExtra(EXTRA_FOLDER);

        rootFragment = new FSFragment().init(folder);
    } else if (intent.hasExtra(EXTRA_STREAM)) {
        rootFragment = new StreamsFragment();
    } else {
        throw new IllegalStateException(debugIntent(intent));
    }

    return rootFragment;
}

From source file:barqsoft.footballscores.Fragments.DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Intent intent = getActivity().getIntent();

    if (intent != null && intent.hasExtra(Intent.EXTRA_TEXT)) {
        mMatch_Id = intent.getStringExtra(Intent.EXTRA_TEXT);
        setFragmentDate(mMatch_Id);//from ww w.  ja v  a2  s.c om
    }

    View rootView = inflater.inflate(R.layout.fragment_detail_start, container, false);

    // Details score list item
    homeName = (TextView) rootView.findViewById(R.id.home_name);
    awayName = (TextView) rootView.findViewById(R.id.away_name);
    homeCrest = (ImageView) rootView.findViewById(R.id.home_crest);
    awayCrest = (ImageView) rootView.findViewById(R.id.away_crest);
    scoreText = (TextView) rootView.findViewById(R.id.score_textview);
    dataDateTextview = (TextView) rootView.findViewById(R.id.data_date_textview);
    leagueTextview = (TextView) rootView.findViewById(R.id.league_textview);
    matchdayTextview = (TextView) rootView.findViewById(R.id.matchday_textview);
    // Share button
    mShareButton = (Button) rootView.findViewById(R.id.share_button);
    mShareButton.setVisibility(View.VISIBLE);

    rootView.findViewById(R.id.scores_list_card).setFocusable(false);

    // Details additional pane
    totalMatches_count = (TextView) rootView.findViewById(R.id.detail_total_matches_count_textview);
    homeTeam_name_add_pane = (TextView) rootView.findViewById(R.id.home_name_label_textview);
    awayTeam_name_add_pane = (TextView) rootView.findViewById(R.id.away_name_label_textview);
    homeTeam_wins_add_pane = (TextView) rootView.findViewById(R.id.detail_home_wins_textview);
    awayTeam_wins_add_pane = (TextView) rootView.findViewById(R.id.detail_away_wins_textview);
    draws_count = (TextView) rootView.findViewById(R.id.detail_draw_count_textview);

    requestQueue = Volley.newRequestQueue(getActivity());

    return rootView;
}

From source file:com.giovanniterlingen.windesheim.view.ScheduleActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent.hasExtra("notification")) {
        boolean fromNotification = intent.getExtras().getBoolean("notification");
        if (fromNotification) {
            setViewPager();/*w w  w.ja  v a  2 s .  com*/
        }
    }
}

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);/* ww  w . j  a  va  2  s .c om*/
                (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.piusvelte.sonet.SelectFriends.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // allow posting to multiple services if an account is defined
    // allow selecting which accounts to use
    // get existing comments, allow liking|unliking those comments
    setContentView(R.layout.friends);/*from  w w  w.j a  v  a2  s .co  m*/
    if (!getPackageName().toLowerCase().contains(PRO)) {
        AdView adView = new AdView(this, AdSize.BANNER, BuildConfig.GOOGLEAD_ID);
        ((LinearLayout) findViewById(R.id.ad)).addView(adView);
        adView.loadAd(new AdRequest());
    }
    Intent intent = getIntent();
    if ((intent != null) && intent.hasExtra(Accounts.SID)) {
        mAccountId = intent.getLongExtra(Accounts.SID, Sonet.INVALID_ACCOUNT_ID);
        String[] tags = intent.getStringArrayExtra(Stags);
        if (tags != null) {
            for (String tag : tags)
                mSelectedFriends.add(tag);
        }
    } else
        finish();

    mHttpClient = SonetHttpClient.getThreadSafeClient(getApplicationContext());
    registerForContextMenu(getListView());
    setResult(RESULT_CANCELED);
}

From source file:com.deliciousdroid.activity.FragmentBaseActivity.java

@Override
@TargetApi(14)/*from  w ww.  j  a v a2s. c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this;
    mAccountManager = AccountManager.get(this);
    settings = PreferenceManager.getDefaultSharedPreferences(this);

    loadSettings();
    init();

    if (android.os.Build.VERSION.SDK_INT >= 14) {
        getActionBar().setHomeButtonEnabled(true);
    }

    Intent intent = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults")) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            Intent i = new Intent(this, MainSearchResults.class);
            i.putExtras(intent.getExtras());
            startActivity(i);
            finish();
        } else {
            onSearchRequested();
        }
    } else if (Constants.ACTION_SEARCH_SUGGESTION.equals(intent.getAction())) {
        Uri data = intent.getData();
        String path = null;
        String tagname = null;

        if (data != null) {
            path = data.getPath();
            tagname = data.getQueryParameter("tagname");
        }

        if (data.getScheme() == null || !data.getScheme().equals("content")) {
            Intent i = new Intent(Intent.ACTION_VIEW, data);
            startActivity(i);
            finish();
        } else if (path.contains("bookmarks") && TextUtils.isDigitsOnly(data.getLastPathSegment())
                && intent.hasExtra(SearchManager.USER_QUERY)) {
            Intent viewBookmark = new Intent(this, ViewBookmark.class);
            viewBookmark.setAction(Intent.ACTION_VIEW);
            viewBookmark.setData(data);
            viewBookmark.removeExtra(SearchManager.USER_QUERY);
            Log.d("View Bookmark Uri", data.toString());
            startActivity(viewBookmark);
            finish();
        } else if (tagname != null) {
            Intent viewTags = new Intent(this, BrowseBookmarks.class);
            viewTags.setData(data);

            Log.d("View Tags Uri", data.toString());
            startActivity(viewTags);
            finish();
        }
    }
}

From source file:com.droid080419.droid080419.elevenfifty_nine.EditTaskActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == AltAddTaskActivity.ADD_TASK_REQUEST && resultCode == RESULT_OK) {
        if (data != null && data.hasExtra("LATITUDE") && data.hasExtra("LONGITUDE")) {
            coords = new LatLng(data.getDoubleExtra("LATITUDE", MapsActivity.UPD.latitude),
                    data.getDoubleExtra("LONGITUDE", MapsActivity.UPD.longitude));
            Log.d("MAPS", "EXTRas");
        }//from   w  w  w  .j  a va  2  s.  com
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

/**
 * As we only ever want one instance of this screen, we set a launchMode of singleTop. This
 * means that instead of re-creating this Activity, a new intent is delivered via this callback.
 * This prevents multiple instances of the search dialog 'stacking up' e.g. if you perform a
 * voice search.//  w ww  .j a va2s . c  om
 *
 * See: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
 */
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent.hasExtra(SearchManager.QUERY)) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (!TextUtils.isEmpty(query)) {
            searchFor(query);
            mSearchView.setQuery(query, false);
        }
    }
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // allow posting to multiple services if an account is defined
    // allow selecting which accounts to use
    // get existing comments, allow liking|unliking those comments
    setContentView(R.layout.friends);//from  w ww  .j  a  va  2s .c  om
    if (!getPackageName().toLowerCase().contains(PRO)) {
        AdView adView = new AdView(this, AdSize.BANNER, SonetTokens.GOOGLE_AD_ID);
        ((LinearLayout) findViewById(R.id.ad)).addView(adView);
        adView.loadAd(new AdRequest());
    }
    Intent intent = getIntent();
    if ((intent != null) && intent.hasExtra(Accounts.SID)) {
        mAccountId = intent.getLongExtra(Accounts.SID, Sonet.INVALID_ACCOUNT_ID);
        String[] tags = intent.getStringArrayExtra(Stags);
        if (tags != null) {
            for (String tag : tags)
                mSelectedFriends.add(tag);
        }
    } else
        finish();

    mHttpClient = SonetHttpClient.getThreadSafeClient(getApplicationContext());
    registerForContextMenu(getListView());
    setResult(RESULT_CANCELED);
}