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:com.example.cuisoap.agrimac.homePage.machineDetail.machineInfoFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        Uri uri = data.getData();
        Log.e("uri", uri.toString());
        ContentResolver cr = context.getContentResolver();
        try {//from   w w w .java 2  s . c o  m
            Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri));
            bitmap = ImageUtils.comp(bitmap);
            switch (requestCode) {
            case 1:
                license_uri1 = uri;
                license_pic1.setImageBitmap(bitmap);
                license_pic1.setVisibility(View.VISIBLE);
                license1.setVisibility(View.GONE);
                license_pic1.setOnClickListener(myOnClickListener);
                machineDetailData.machine_license_filepath1 = ImageUtils.saveMyBitmap(bitmap, null);
                break;
            case 2:
                license_uri2 = uri;
                license_pic2.setImageBitmap(bitmap);
                license_pic2.setVisibility(View.VISIBLE);
                license2.setVisibility(View.GONE);
                license_pic2.setOnClickListener(myOnClickListener);
                machineDetailData.machine_license_filepath2 = ImageUtils.saveMyBitmap(bitmap, null);
                break;
            }
        } catch (FileNotFoundException e) {
            Log.e("Exception", e.getMessage(), e);
        }
    } else {
        Toast.makeText(context, "?", Toast.LENGTH_SHORT).show();
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:au.com.cybersearch2.classyfy.TitleSearchResultsActivity.java

/**
 * Parse intent - ACTION_SEARCH or ACTION_VIEW
 * @param intent Intent object/*from w ww  .ja v  a  2 s  . c o  m*/
 */
protected void parseIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String searchQuery = intent.getStringExtra(SearchManager.QUERY);
        if (searchQuery != null)
            launchSearch(searchQuery, ticketManager.addIntent(intent));
    }
    if (Intent.ACTION_VIEW.equals(intent.getAction()) && (intent.getData() != null))
        viewUri(intent.getData(), ticketManager.addIntent(intent));

}

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;
    }/*w w w.  j ava2 s.  co 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:com.liquid.wallpapers.free.ScroidWallpaperGallery.java

private void onPickContactActivityResult(int resultCode, Intent data) {
    if (resultCode == 0) {
        return;// ww w .  j a v  a  2s .c  o  m
    }

    Communication[] communications = this.communicationDAO.getCommunications(data.getData());

    if (communications.length < 1) {
        AlertDialogFactory.showInfoMessage(this, R.string.infoText, R.string.noCommunicationFoundInfoText);

        return;
    }

    CommunicationChooseDialog dialog = new CommunicationChooseDialog(this, communications,
            new CommunicationChosenListener() {

                /*
                * (non-Javadoc)
                * 
                * @see de.dan_nrw.android.scroid.core.communications.
                * CommunicationChooseDialog
                * .CommunicationChosenListener#onCommunicationChosen
                * (de.dan_nrw.android.scroid.Communication)
                */
                @Override
                public void onCommunicationChosen(Communication communication) {
                    handleOnCommunicationChosen(communication);
                }
            });

    dialog.show();
}

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;
        }/*from w  w  w .  j  a v a2 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.orange.ocara.ui.activity.ListAuditActivity.java

@OnActivityResult(ACTION_CREATE_NEW_DOCUMENT)
void onCreateDocument(int resultCode, Intent data) {

    if (resultCode == Activity.RESULT_OK) {
        Uri uri = data.getData();
        copyFile(exportFile, uri);/*from ww w. ja  va  2s .c o  m*/
    }
}

From source file:abanoubm.dayra.main.Main.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == IMPORT_DB) {
            String path = Utility.getRealPath(getApplicationContext(), data.getData());

            if (path == null) {
                Toast.makeText(getApplicationContext(), R.string.err_msg_invalid_path, Toast.LENGTH_LONG)
                        .show();/*from  ww w  .j  a va 2 s  .  c  o  m*/
                return;
            }

            String dbname = path.substring(path.lastIndexOf("/") + 1);
            if (Utility.isInvlaidDBName(dbname))
                Toast.makeText(getApplicationContext(), R.string.err_msg_dayra_name, Toast.LENGTH_SHORT).show();
            else if (DB.isDBExists(getApplicationContext(), dbname))
                Toast.makeText(getApplicationContext(), R.string.err_msg_duplicate_dayra, Toast.LENGTH_SHORT)
                        .show();
            else
                new ImportDayraFileTask().execute(dbname, path);

        }

    }

}

From source file:org.blanco.techmun.android.MensajesActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0 && resultCode == RESULT_OK) {
        Cursor c = managedQuery(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null,
                "_id = " + 1, null, null);
        if (c != null && c.moveToNext()) {
            Uri selectedImage = data.getData();
            String[] filePathColumn = { MediaStore.Images.Media.DATA };

            Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
            cursor.moveToFirst();//from  w  w  w .j  a  v a  2s  .  c  om

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String filePath = cursor.getString(columnIndex);
            cursor.close();

            attachImage = BitmapFactory.decodeFile(filePath);
            //Mark the button as image attached
            btnAddImage.setBackgroundColor(Color.YELLOW);
            Log.i("techmun", "selected image" + filePath + " Loaded.");

        }
        Log.d("techmun", "Returned from image pick");

    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.example.ridemedriver.SignupStepTwoActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    Log.i("WWQQ", "in onActivityResult()");
    switch (requestCode) {
    case 1:/*from w  ww . j  av  a  2 s.c o m*/
        if (resultCode == RESULT_OK) {
            cropPhoto(data.getData());//?
        }
        break;
    case 2:
        if (resultCode == RESULT_OK) {
            File temp = new File(Environment.getExternalStorageDirectory() + "/head.jpg");
            cropPhoto(Uri.fromFile(temp));//?
        }
        break;
    case 3:
        if (data != null) {
            Bundle extras = data.getExtras();
            avatar_pic = extras.getParcelable("data");
            if (avatar_pic != null) {
                FileOutputStream b = null;
                File file = new File(path);
                file.mkdirs();// 
                String fileName = path + "upload_avata";//??
                try {
                    b = new FileOutputStream(fileName);
                    avatar_pic.compress(Bitmap.CompressFormat.JPEG, 100, b);// ?
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } finally {
                    try {
                        //?
                        b.flush();
                        b.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                signup_steptwo_avatar_imgview.setImageBitmap(avatar_pic);//ImageView?
            }
        }
        break;
    default:
        break;

    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:cw.kop.autobackground.settings.AppSettingsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
    case TutorialActivity.TUTORIAL_REQUEST:
        restartActivity();/*from w  w  w  .  ja va2 s .  co  m*/
        break;
    case IMPORT_SOURCES_REQUEST_CODE:
        if (resultCode == Activity.RESULT_OK) {
            File file = new File(data.getData().getPath());
            importSources(file);
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}