android-intent

Android Intent.ACTION_VIEW

拟墨画扇 提交于 2019-12-22 09:04:45
问题 I need to user choice their own player to play video and I try public class VideoViewActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String videoUrl = "http://someurl/video.mp4"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(videoUrl)); startActivity(i); } But in my example activity open browser not a list of current installed player. Which option of Intent I should use? Is it possible? 回答1: Please

Android: Get Time Spent Per Activity

安稳与你 提交于 2019-12-22 08:59:19
问题 Firstly, I'm not looking for time spent on a given application. There is already "an app for that", com.android.settings/.UsageStats , and a good deal of supporting code in the AOSP frameworks/base/services/java/com/android/server/am/UsageStatsService.java , etc. The code that I've examined so far does not seem to record elapsed time spent on particular <activity> s . I have thought to get this information two ways, but feel there must be something cleaner and simpler, that leverages more

How to run a application in the foreground on Android versions below 5.1

浪尽此生 提交于 2019-12-22 08:50:51
问题 I have implemented a small timer application and it is starting whenever I received a call, Like after receiving an incoming call I am starting my timer application and displaying timer in foreground. But it is working in lollipop 5.1 version in lower end version it is running in background. I need to run application in foreground in all devices, how to achieve this? My code: Intent it = new Intent("intent.my.action"); it.setComponent(new ComponentName(context.getPackageName(), timer.class

Can't save files on External Storage, even with user permissions [Android]

丶灬走出姿态 提交于 2019-12-22 08:17:46
问题 I'm developing an app for images manipulation on Android, but I'm stuck in writing the code for image saving. Here's the method I use: private void saveImageToExternalStorage(Bitmap finalBitmap) { String root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString(); File myDir = new File(root + "/saved_images"); myDir.mkdirs(); Random generator = new Random(); int n = 10000; n = generator.nextInt(n); String fname = "Image-" + n + ".jpg"; File file = new File

How to share Html text to whatsapp intent

爱⌒轻易说出口 提交于 2019-12-22 08:06:49
问题 I want to share Html text via whatsapp intent . The code I have written is below. Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(new StringBuilder() .append("<p><b>Some Content</b></p>") .append("<small><p>More content</p></small>") .toString())); this.getContext().startActivity(Intent.createChooser(sharingIntent,"Share using")); But whatsapp application is not showing in Intent chooser list.

Open Instagram from Android Browser

心不动则不痛 提交于 2019-12-22 07:19:18
问题 Intent, hooks, API, integration, dozen of cryptic javascripts, xml schemas, URL interpreters, helpers, frameworks... It's 3 days that i'm reading blogs, SDK, tutorials to achive a very simple goal: open Instagram by clicking an URL in the Android browser. I find it a bit incredible that i needed 5 minutes to make it on iOS. I don't even know what code i should share since i don't even succeded in having an error... at least it would be something! To make it short i have an Android phone. I

Wrapping Intent in LabeledIntent for display purposes

别等时光非礼了梦想. 提交于 2019-12-22 07:11:00
问题 The Requirements: I have a "share" button in my app. I have a requirement to share via Facebook. I need to have the option whether or not the native Facebook app is installed. Our decision is to send the user to facebook.com to share if the app is not installed. The Current State: I can detect when the native app is not installed (via the package name), and add additional intents to the chooser. The Problem: The item the user has to select to share via "Facebook's Website" says, "Browser" and

How to add your application to the “Share” menu with monodroid

孤人 提交于 2019-12-22 07:05:56
问题 My solution is based on this article: http://twigstechtips.blogspot.com/2011/10/android-sharing-images-or-files-through.html 回答1: You have to add [IntentFilter(new[]{Intent.ActionSend},Categories = new[]{Intent.CategoryDefault},DataMimeType = "image/*",Label = "Your application name")] before your class declaration. Like this: [Activity(Label = "Activity label", ScreenOrientation = ScreenOrientation.Portrait)] [IntentFilter(new[]{Intent.ActionSend},Categories = new[]{Intent.CategoryDefault}

Deep Link not working in Chrome for Android

孤人 提交于 2019-12-22 07:05:11
问题 I have an intent-filter defined for my application, which goes like this: !-- Accepts URIs that begin with "urban://success” --> <data android:host="success" android:scheme="urban" /> This deep link seems to be working for other browsers, but for Chrome for android it does not. The answer I get from the server looks like this: urban://success?utf8=%E2%9C%93&json=%7B%22status%22%3A%... Any help will be appreciated. Best regards. 回答1: You need to annotate the deep links using href="android-app:

getIntent().getStringExtra() shows null

寵の児 提交于 2019-12-22 06:41:08
问题 I m using one EditText field and one spinner. I have to pass teh results of both to the next Activity. here, reqd_bloodgroup is the spinner item, i converted into String using: reqd_bloodgrp = String.valueOf(spinner.getSelectedItem()); inside onItemSelected() of spinner. intent.putExtra("city", citySelected.getText().toString()); intent.putExtra("bloodgroup", reqd_bloodgrp); intent = new Intent(FindDonor.this,SpecificDonor.class); startActivity(intent); Here when i try to display these, there