Java Code Examples for android.content.Intent#setData()

The following examples show how to use android.content.Intent#setData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemHelper.java    From DoingDaily with Apache License 2.0 6 votes vote down vote up
/**
 * 调用系统浏览器
 *
 * @param context
 * @param url
 */
public static void SystemBrowser(Context context, String url) {

    if (context == null) {
        return;
    }

    if (TextUtils.isEmpty(url)) {
        return;
    }

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    Uri content_url = Uri.parse(url);
    intent.setData(content_url);

    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(Intent.createChooser(intent, context.getString(R.string.tips_select_browser)));
    }
}
 
Example 2
Source File: StandaloneActivity.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@Override
public void onDocumentPicked(DocumentInfo doc) {
    final FragmentManager fm = getFragmentManager();
    if (doc.isDirectory()) {
        mState.stack.push(doc);
        mState.stackTouched = true;
        onCurrentDirectoryChanged(ANIM_DOWN);
    } else {
        // Fall back to viewing
        final Intent view = new Intent(Intent.ACTION_VIEW);
        view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        view.setData(doc.derivedUri);
        try {
            startActivity(view);
        } catch (ActivityNotFoundException ex2) {
            Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example 3
Source File: LinksCard.java    From narrate-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {

    String url = null;

    switch ((String)v.getTag()) {
        case "community":
            url = "https://plus.google.com/communities/106662199081610755624";
            break;
        case "github":
            url = "https://github.com/timothymiko/narrate-android";
            break;
        case "tasker":
            url = "https://github.com/timothymiko/narrate-android";
            break;
    }

    if ( url != null ) {
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        getContext().startActivity(i);
    }
}
 
Example 4
Source File: ToggleWidget.java    From BatteryFu with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialise the widget views and click handlers
 * @param context
 * @param remoteViews
 */
private void initWidget(Context context, RemoteViews remoteViews) {
	// put the right icon image on
	Settings settings = Settings.getSettings(context);
	if (settings.isEnabled()) {
		remoteViews.setImageViewResource(R.id.widget_icon, R.drawable.widget_icon_toggle_on);
	} else {
		remoteViews.setImageViewResource(R.id.widget_icon, R.drawable.widget_icon_toggle_off);
	}
	
	// separate intent for clicking the icon
	Intent active = new Intent(context, ToggleWidget.class);
	active.setAction(ACTION_WIDGET_RECEIVER);
	active.setData(Uri.parse("click://icon"));
	PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0);		
	remoteViews.setOnClickPendingIntent(R.id.widget_icon, actionPendingIntent);
	
	// vs clicking the text
	active.setData(Uri.parse("click://text"));
	actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0);		
	remoteViews.setOnClickPendingIntent(R.id.widget_text, actionPendingIntent);
}
 
Example 5
Source File: MainActivity.java    From RedReader with GNU General Public License v3.0 6 votes vote down vote up
public void onSelected(final PostListingURL url) {

		if(url == null) {
			return;
		}

		if(twoPane) {

			postListingController = new PostListingController(url, this);
			requestRefresh(RefreshableFragment.POSTS, false);

		} else {
			final Intent intent = new Intent(this, PostListingActivity.class);
			intent.setData(url.generateJsonUri());
			startActivityForResult(intent, 1);
		}
	}
 
Example 6
Source File: VmIntentResolver.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
public Intent getDetailIntent(Vm entity, Context context, MovirtAccount account) {
    if (account == null || entity == null || context == null) {
        return null;
    }

    Intent intent = new Intent(context, VmDetailActivity_.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setData(entity.getUri());
    intent.putExtra(Constants.ACCOUNT_KEY, account);

    return intent;
}
 
Example 7
Source File: MainActivity.java    From android-dev-challenge with Apache License 2.0 5 votes vote down vote up
/**
     * This method is for responding to clicks from our list.
     *
     * @param weatherForDay String describing weather details for a particular day
     */
    @Override
    public void onClick(long date) {
//      COMPLETED (39) Refactor onClick to build a URI for the clicked date and and pass it with the Intent using setData
        Intent weatherDetailIntent = new Intent(MainActivity.this, DetailActivity.class);
        Uri uriForDateClicked = WeatherContract.WeatherEntry.buildWeatherUriWithDate(date);
        weatherDetailIntent.setData(uriForDateClicked);

        startActivity(weatherDetailIntent);
    }
 
Example 8
Source File: NotificationState.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
public PendingIntent getQuickReplyIntent(Context context, Recipients recipients) {
  if (threads.size() != 1) throw new AssertionError("We only support replies to single thread notifications! " + threads.size());

  Intent     intent           = new Intent(context, ConversationPopupActivity.class);
  intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
  intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, (long)threads.toArray()[0]);
  intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));

  return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
 
Example 9
Source File: ws_Main3Activity.java    From styT with Apache License 2.0 5 votes vote down vote up
public void ajoinQQGroupdata(String key) {
        Intent intent = new Intent();
        intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面    //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        try {
            startActivity(intent);
        } catch (Exception e) {
// 未安装手Q或安装的版本不支持
        }
    }
 
Example 10
Source File: TabMainActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
public void showHongBaoBalance() {
    if (!TextUtils.isEmpty(QtalkNavicationService.HONGBAO_BALANCE)) {
        Uri uri = Uri.parse(QtalkNavicationService.HONGBAO_BALANCE);
        Intent intent = new Intent(this, QunarWebActvity.class);
        intent.putExtra(Constants.BundleKey.WEB_FROM, Constants.BundleValue.HONGBAO);
        intent.setData(uri);
        startActivity(intent);
    }
}
 
Example 11
Source File: IntentUtil.java    From android-atleap with Apache License 2.0 5 votes vote down vote up
/**
 * Create Intent for sending sms.
 *
 * @param phoneNumber telephone number
 * @param body        body of sms
 * @return created intent
 */
public static Intent sendSms(String phoneNumber, String body) {
    Intent intent = createIntent(Intent.ACTION_VIEW, null, null);
    if (!TextUtils.isEmpty(phoneNumber)) {
        intent.setData(Uri.parse("sms:" + phoneNumber));
    } else {
        intent.setData(Uri.parse("sms:"));
        //intent.setType("vnd.android-dir/mms-sms");
    }

    intent.putExtra("sms_body", body);
    return intent;
}
 
Example 12
Source File: AboutActivity.java    From android with MIT License 4 votes vote down vote up
/**
 * @return an {@link Intent} that opens the given {@code url}
 */
private static Intent getActionIntent(final String url) {
    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    return intent;
}
 
Example 13
Source File: SettingsFragment.java    From Shelter with Do What The F*ck You Want To Public License 4 votes vote down vote up
private boolean openSummaryUrl(Preference pref) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(pref.getSummary().toString()));
    startActivity(intent);
    return true;
}
 
Example 14
Source File: SettingsActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
private void openUrl(String url) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(i);
}
 
Example 15
Source File: AboutActivity.java    From materialize with GNU General Public License v3.0 4 votes vote down vote up
private void open(String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}
 
Example 16
Source File: Service.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates and returns an intent that navigates the user to the Google Play landing page for the app
 *
 * @return The intent
 */
public static Intent getPlayStoreIntent() {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=net.nrask.notifyme"));
    return intent;
}
 
Example 17
Source File: MainActivity.java    From NYU-BusTracker-Android with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("UnusedParameters")
public void callSafeRide(View view) {
    Intent callIntent = new Intent(Intent.ACTION_DIAL);
    callIntent.setData(Uri.parse("tel:12129928267"));
    startActivity(callIntent);
}
 
Example 18
Source File: HomeActivity.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
public static Intent userDonationIntent() {
    String url = "https://abhijitvalluri.com/android/donate";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    return i;
}
 
Example 19
Source File: SettingsFragment.java    From ground-android with Apache License 2.0 4 votes vote down vote up
private void openUrl(String url) {
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse(url));
  startActivity(intent);
}
 
Example 20
Source File: GeoHelper.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
public static ArrayList<Intent> createGeoIntentsFromMessage(Context context, Message message) {
	final ArrayList<Intent> intents = new ArrayList<>();
	final GeoPoint geoPoint;
	try {
		geoPoint = parseGeoPoint(message.getBody());
	} catch (IllegalArgumentException e) {
		return intents;
	}
	final Conversational conversation = message.getConversation();
	final String label = getLabel(context, message);

	if (isLocationPluginInstalledAndDesired(context)) {
		Intent locationPluginIntent = new Intent(SHOW_LOCATION_PACKAGE_NAME);
		locationPluginIntent.putExtra("latitude", geoPoint.getLatitude());
		locationPluginIntent.putExtra("longitude", geoPoint.getLongitude());
		if (message.getStatus() != Message.STATUS_RECEIVED) {
			locationPluginIntent.putExtra("jid", conversation.getAccount().getJid().toString());
			locationPluginIntent.putExtra("name", conversation.getAccount().getJid().getLocal());
		} else {
			Contact contact = message.getContact();
			if (contact != null) {
				locationPluginIntent.putExtra("name", contact.getDisplayName());
				locationPluginIntent.putExtra("jid", contact.getJid().toString());
			} else {
				locationPluginIntent.putExtra("name", UIHelper.getDisplayedMucCounterpart(message.getCounterpart()));
			}
		}
		intents.add(locationPluginIntent);
	} else {
		Intent intent = new Intent(context, ShowLocationActivity.class);
		intent.setAction(SHOW_LOCATION_PACKAGE_NAME);
		intent.putExtra("latitude", geoPoint.getLatitude());
		intent.putExtra("longitude", geoPoint.getLongitude());
		intents.add(intent);
	}

	intents.add(geoIntent(geoPoint, label));

	Intent httpIntent = new Intent(Intent.ACTION_VIEW);
	httpIntent.setData(Uri.parse("https://maps.google.com/maps?q=loc:"+String.valueOf(geoPoint.getLatitude()) + "," + String.valueOf(geoPoint.getLongitude()) +label));
	intents.add(httpIntent);
	return intents;
}