Example usage for android.content Intent getData

List of usage examples for android.content Intent getData

Introduction

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

Prototype

public @Nullable Uri getData() 

Source Link

Document

Retrieve data this intent is operating on.

Usage

From source file:be.ppareit.swiftp.gui.PreferenceFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
    if (requestCode == ACTION_OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK) {
        Uri treeUri = resultData.getData();
        String path = treeUri.getPath();

        final CheckBoxPreference writeExternalStorage_pref = findPref("writeExternalStorage");
        if (!":".equals(path.substring(path.length() - 1)) || path.contains("primary")) {
            writeExternalStorage_pref.setChecked(false);
        } else {//from  www .ja v a  2s. co m
            FsSettings.setExternalStorageUri(treeUri.toString());
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                getActivity().getContentResolver().takePersistableUriPermission(treeUri,
                        Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            }
            writeExternalStorage_pref.setChecked(true);
        }
    }

}

From source file:com.intel.xdk.contacts.Contacts.java

@SuppressWarnings("deprecation")
public void contactsChooserActivityResult(int requestCode, int resultCode, Intent intent) {

    if (resultCode == Activity.RESULT_OK) {
        Cursor cursor = activity.managedQuery(intent.getData(), null, null, null, null);
        cursor.moveToNext();/*w w w  .  ja v a 2  s . c  om*/
        String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
        String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));

        getAllContacts();
        String js = String.format(
                " var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.choose',true,true);e.success=true;e.contactid='%s';document.dispatchEvent(e);",
                contactId);
        injectJS("javascript:" + js);
        busy = false;
    } else {
        String js = "var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.choose',true,true);e.success=false;e.message='User canceled';document.dispatchEvent(e);";
        injectJS("javascript:" + js);
        busy = false;
    }

}

From source file:com.vuze.android.remote.AppPreferences.java

public void showRateDialog(final Activity mContext) {

    if (!shouldShowRatingReminder()) {
        return;/*w  ww  . j  a  va2 s  .c om*/
    }

    // skip showing if they are adding a torrent (or anything else)
    Intent intent = mContext.getIntent();
    if (intent != null) {
        Uri data = intent.getData();
        if (data != null) {
            return;
        }
    }

    // even if something goes wrong, we want to set that we asked, so
    // it doesn't continue to pop up
    setAskedRating();

    Dialog dialog = new Dialog(mContext);

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage(R.string.ask_rating_message).setCancelable(false)
            .setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final String appPackageName = mContext.getPackageName();
                    try {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("market://details?id=" + appPackageName)));
                    } catch (android.content.ActivityNotFoundException anfe) {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
                    }
                    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskStoreClick",
                            null);
                }
            }).setNeutralButton(R.string.later, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).setNegativeButton(R.string.no_thanks, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    setNeverAskRatingAgain();
                }
            });
    dialog = builder.create();

    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskShown", null);
    dialog.show();
}

From source file:ca.rmen.android.scrumchatter.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //StrictMode.setThreadPolicy(new ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().penaltyLog().penaltyDeath().build());
    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override// w  w w.  ja  va  2  s  .c  o m
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    onTeamChanged();
    // If our activity was opened by choosing a file from a mail attachment, file browser, or other program, 
    // import the database from this file.
    Intent intent = getIntent();
    if (intent != null) {
        if (Intent.ACTION_VIEW.equals(intent.getAction()))
            importDB(intent.getData());
    }
}

From source file:br.com.anteros.social.instagram.AnterosInstagramSession.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    int sanitizedRequestCode = requestCode & 0xFFFF;
    if (sanitizedRequestCode != REQUEST_AUTH)
        return;//  ww w .j av a  2 s .  c  om

    Uri uri = data != null ? data.getData() : null;

    if (uri != null && uri.toString().startsWith(redirectURL)) {
        String parts[] = uri.toString().split("=");
        String verifier = parts[1];
        RequestLoginAsyncTask requestLogin2AsyncTask = new RequestLoginAsyncTask();
        mRequests.put(REQUEST_LOGIN, requestLogin2AsyncTask);
        Bundle args = new Bundle();
        args.putString(RequestLoginAsyncTask.PARAM_VERIFIER, verifier);
        requestLogin2AsyncTask.execute(args);
    } else {
        onLoginListener.get().onFail(new AnterosInstagramException("Incorrect URI returned " + uri));
    }
}

From source file:org.ueu.uninet.it.IragarkiaBidali.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case PICK_IMAGE:
        if (resultCode == Activity.RESULT_OK) {
            Uri selectedImageUri = data.getData();

            try {
                // OI Fitxategi kudeatzailea
                String filemanagerstring = selectedImageUri.getPath();

                // MEDIA galeria
                String selectedImagePath = getPath(selectedImageUri);

                if (selectedImagePath != null) {
                    filePath = selectedImagePath;
                } else if (filemanagerstring != null) {
                    filePath = filemanagerstring;
                } else {
                    Toast.makeText(getApplicationContext(), "Kokapen ezezaguna", Toast.LENGTH_LONG).show();
                }//from ww w .j a  va2s . com

                if (filePath != null) {
                    Thread haria = new Thread() {
                        @Override
                        public void run() {
                            decodeFile(filePath);
                        }
                    };
                    haria.run();

                } else {
                    bitmap = null;
                }
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), "Barne-errore bat egon da.", Toast.LENGTH_LONG).show();
            }
        }
        break;
    default:
    }
}

From source file:com.intel.xdk.contacts.Contacts.java

@SuppressWarnings("deprecation")
public void contactsAdderActivityResult(int requestCode, int resultCode, Intent intent) {

    //Contact Added
    if (resultCode == Activity.RESULT_OK) {
        Cursor cursor = activity.managedQuery(intent.getData(), null, null, null, null);
        cursor.moveToNext();/*from   www. j a va  2  s  .co  m*/
        String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));

        getAllContacts();
        String js = String.format(
                "var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.add',true,true);e.success=true;e.contactid='%s';document.dispatchEvent(e);",
                contactId);

        injectJS("javascript:" + js);
        busy = false;
    }
    //Contact not Added
    else {
        String js = "javascript: var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.add',true,true);e.success=false;e.cancelled=true;document.dispatchEvent(e);";
        injectJS(js);
        busy = false;
    }

}

From source file:com.sq.jzq.company.MyDataCompanyActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    type = requestCode + "";
    switch (resultCode) {
    case 1://w ww.j  a v  a2 s  .  c o m
        if (data != null) {
            //?Uri,Uri???Uri??  
            Uri mImageCaptureUri = data.getData();
            //Uri???Uri???  
            if (mImageCaptureUri != null) {
                Bitmap image;
                try {
                    //?Uri?Bitmap??  
                    image = MediaStore.Images.Media.getBitmap(this.getContentResolver(), mImageCaptureUri);
                    if (image != null) {
                        //                             CacheImage.setImageForImageView(User.IconPath, ivIcon);
                        if ("7".equals(type)) {
                            iv_my_head.setImageBitmap(image);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                Bundle extras = data.getExtras();
                if (extras != null) {
                    //??Bundle???Bitmap  
                    Bitmap image = extras.getParcelable("data");
                    if (image != null) {
                        if ("7".equals(type)) {
                            iv_my_head.setImageBitmap(image);
                        }
                    }
                }
            }

        }
        new UpdateIcon().update(type);
        break;
    default:
        break;
    }

}

From source file:at.tomtasche.reader.ui.activity.DocumentActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    if (intent == null)
        return;//w w  w.  ja  v  a 2  s . c  o  m

    Uri uri = intent.getData();
    if (requestCode == 42 && resultCode == RESULT_OK && uri != null)
        loadUri(uri);
}

From source file:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java

private boolean openTreeByIntent(Intent intent) {
    if (FBReaderIntents.Action.OPEN_NETWORK_CATALOG.equals(intent.getAction())) {
        final Uri uri = intent.getData();
        if (uri != null) {
            final NetworkTree tree = NetworkLibrary.Instance().getCatalogTreeByUrl(uri.toString());
            if (tree != null) {
                checkAndRun(new OpenCatalogAction(this), tree);
                return true;
            }// www  . ja  v a 2s  . c om
        }
    }
    return false;
}