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:mobisocial.socialkit.musubi.Musubi.java

public void setDataFromIntent(Intent intent) {
    if (intent.hasExtra(EXTRA_FEED_URI)) {
        mFeed = new DbFeed(this, (Uri) intent.getParcelableExtra(EXTRA_FEED_URI));
    }//ww w. j a  v  a2  s. c o  m
    if (mObj == null) {
        if (intent.hasExtra(EXTRA_OBJ_URI)) {
            mObj = objForUri((Uri) intent.getParcelableExtra(EXTRA_OBJ_URI));
        } else {
            mObj = objForUri(intent.getData());
        }
    }
}

From source file:com.kdao.cmpe235_project.UploadActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    System.out.println(">>>> On activity result: " + resultCode + "<<<<<<<<");
    if (resultCode == Activity.RESULT_OK) {
        Uri uri = data.getData();
        try {/*from  w ww .  ja v  a2 s . c om*/
            String path = getPath(uri);
            boolean isCompleted = beginUpload(path);
            if (isCompleted) {
                File file = new File(path);
                addUploadedFIleToDB(APIurl, treeId, file.getName());
            }
        } catch (URISyntaxException e) {
            Toast.makeText(this, Config.UPLOAD_ERROR, Toast.LENGTH_LONG).show();
            Log.e(TAG, "Unable to upload file from the given uri", e);
        }
    }
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java

/**
 * Fires notifications that have elapsed and sets an alarm to be woken at
 * the next notification./*w  ww . j a v a2  s. com*/
 * <p/>
 * If the intent action is ACTION_DELETE, will delete the notification with
 * the indicated ID, and cancel it from any active notifications.
 */
@Override
public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())
            || Intent.ACTION_RUN.equals(intent.getAction())) {
        // Can't cancel anything. Just schedule and notify at end
    } else {
        // Always cancel
        cancelNotification(context, intent.getData());

        if (Intent.ACTION_DELETE.equals(intent.getAction()) || ACTION_RESCHEDULE.equals(intent.getAction())) {
            // Just a notification
            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .deleteOrReschedule(context, intent.getData());
        } else if (ACTION_SNOOZE.equals(intent.getAction())) {
            // msec/sec * sec/min * 30
            long delay30min = 1000 * 60 * 30;
            final Calendar now = Calendar.getInstance();

            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .setTime(context, intent.getData(), delay30min + now.getTimeInMillis());
        } else if (ACTION_COMPLETE.equals(intent.getAction())) {
            // Complete note
            Task.setCompletedSynced(context, true, intent.getLongExtra(ARG_TASKID, -1));
            // Delete notifications with the same task id
            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .removeWithTaskIdsSynced(context, intent.getLongExtra(ARG_TASKID, -1));
        }
    }

    notifyPast(context, true);
    scheduleNext(context);
}

From source file:bolts.AppLinkTest.java

public void testSimpleAppLinkURLNavigationExplicit() throws Exception {
    String html = getHtmlWithMetaTags("al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url",
            "bolts://", "al:android:class", "bolts.utils.BoltsActivity", "al:android:app_name", "Bolts");
    Uri uri = getURLForData(html);//  w w  w .j a  va  2s  .c o  m

    Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor,
            uri);
    waitForTask(task);
    AppLinkNavigation.NavigationResult navigationType = task.getResult();

    assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType);
    assertEquals(1, openedIntents.size());

    Intent openedIntent = openedIntents.get(0);
    assertEquals(uri, AppLinks.getTargetUrl(openedIntent));
    assertEquals("bolts", openedIntent.getData().getScheme());
}

From source file:bolts.AppLinkTest.java

public void testSimpleAppLinkURLNavigationImplicit() throws Exception {
    // Don't provide a class name so that implicit resolution occurs.
    String html = getHtmlWithMetaTags("al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url",
            "bolts://", "al:android:app_name", "Bolts");
    Uri uri = getURLForData(html);/*from w  ww  .j av a 2s .c o m*/

    Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor,
            uri);
    waitForTask(task);
    AppLinkNavigation.NavigationResult navigationType = task.getResult();

    assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType);
    assertEquals(1, openedIntents.size());

    Intent openedIntent = openedIntents.get(0);
    assertEquals(uri, AppLinks.getTargetUrl(openedIntent));
    assertEquals("bolts", openedIntent.getData().getScheme());
}

From source file:bolts.AppLinkTest.java

public void testAppLinkURLNavigationMultipleTargetsNoFallbackExplicit() throws Exception {
    String html = getHtmlWithMetaTags("al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url",
            "bolts://", "al:android:class", "bolts.utils.BoltsActivity", "al:android:app_name", "Bolts",

            "al:android", "al:android:package", PACKAGE_NAME, "al:android:url", "bolts2://", "al:android:class",
            "bolts.utils.BoltsActivity2", "al:android:app_name", "Bolts 2");
    Uri uri = getURLForData(html);//  w ww .  ja v  a 2  s.  c  o  m

    Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor,
            uri);
    waitForTask(task);
    AppLinkNavigation.NavigationResult navigationType = task.getResult();

    assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType);
    assertEquals(1, openedIntents.size());

    Intent openedIntent = openedIntents.get(0);
    assertEquals(uri, AppLinks.getTargetUrl(openedIntent));
    assertEquals("bolts", openedIntent.getData().getScheme());
}

From source file:bolts.AppLinkTest.java

public void testAppLinkURLNavigationMultipleTargetsNoFallbackImplicit() throws Exception {
    // Remove the class name to make it implicit
    String html = getHtmlWithMetaTags("al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url",
            "bolts://", "al:android:app_name", "Bolts",

            "al:android", "al:android:package", PACKAGE_NAME, "al:android:url", "bolts2://",
            "al:android:app_name", "Bolts 2");
    Uri uri = getURLForData(html);/*w  ww.j  av  a 2s .co  m*/

    Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor,
            uri);
    waitForTask(task);
    AppLinkNavigation.NavigationResult navigationType = task.getResult();

    assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType);
    assertEquals(1, openedIntents.size());

    Intent openedIntent = openedIntents.get(0);
    assertEquals(uri, AppLinks.getTargetUrl(openedIntent));
    assertEquals("bolts", openedIntent.getData().getScheme());
}

From source file:bolts.AppLinkTest.java

public void testAppLinkURLNavigationMultipleTargetsWithFallbackExplicit() throws Exception {
    String html = getHtmlWithMetaTags("al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url",
            "bolts://", "al:android:class", "bolts.utils.InvalidActivity", "al:android:app_name", "Bolts",

            "al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url", "bolts2://",
            "al:android:class", "bolts.utils.BoltsActivity2", "al:android:app_name", "Bolts 2");
    Uri uri = getURLForData(html);/*  www .jav  a2  s.  c  o  m*/

    Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor,
            uri);
    waitForTask(task);
    AppLinkNavigation.NavigationResult navigationType = task.getResult();

    assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType);
    assertEquals(1, openedIntents.size());

    Intent openedIntent = openedIntents.get(0);
    assertEquals(uri, AppLinks.getTargetUrl(openedIntent));
    assertEquals("bolts2", openedIntent.getData().getScheme());
}

From source file:bolts.AppLinkTest.java

public void testAppLinkURLNavigationMultipleTargetsWithFallbackImplicit() throws Exception {
    // Remove the class name to make it implicit
    String html = getHtmlWithMetaTags("al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url",
            "invalid://", "al:android:app_name", "Bolts",

            "al:android", null, "al:android:package", PACKAGE_NAME, "al:android:url", "bolts2://",
            "al:android:app_name", "Bolts 2");
    Uri uri = getURLForData(html);// w w  w . j  ava  2s  .c o  m

    Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor,
            uri);
    waitForTask(task);
    AppLinkNavigation.NavigationResult navigationType = task.getResult();

    assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType);
    assertEquals(1, openedIntents.size());

    Intent openedIntent = openedIntents.get(0);
    assertEquals(uri, AppLinks.getTargetUrl(openedIntent));
    assertEquals("bolts2", openedIntent.getData().getScheme());
}

From source file:com.google.zxing.client.android.CaptureActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i("djf", "onActivityResult");
    mGalleryPic.setVisibility(View.GONE);
    mGalleryPic.setImageBitmap(null);// w w w .  ja v  a  2  s  .  c om
    mFailText.setVisibility(View.GONE);
    mFailText.setText(null);
    if (requestCode == JsConst.START_IMAGE_INTENT && resultCode == RESULT_OK && null != data) {
        ScanLocalImageAsyncTask task = new ScanLocalImageAsyncTask(data.getData());
        task.execute();
    } else {
        resetStatusView();
    }
}