Posts

Showing posts with the label Android Intent

Advantages Of Using Bundle Instead Of Direct Intent PutExtra() In Android

Answer : It makes little (if any difference). The code using an additional bundle is slightly heavier (it won't make any difference in any practical application) and slightly easier to manage, being more general. If one day you decide that - before sending information inside an intent - you want to serialize the data to database - it will be a bit cleaner to have a bundle that you can serialize, add to an intent and then feed to a PendingBundle - all with one object. [update] A clarification (because of some other answers). Extras is an additional bundle that each Intent might carry (but doesn't have to), so there is no alternative between using a bundle or not using it. You are using a bundle either way. The first time you use putExtra , a mExtras bundle inside Intent is initialized and all the following putExtra are delegated to it. The bundle itself is inaccessible to you (this is by design, to avoid certain kind of bugs). putExtras does not put your bundle...

Android - Adding At Least One Activity With An ACTION-VIEW Intent-filter After Updating SDK Version 23

Answer : From official documentation : To enable Google to crawl your app content and allow users to enter your app from search results, you must add intent filters for the relevant activities in your app manifest. These intent filters allow deep linking to the content in any of your activities. For example, the user might click on a deep link to view a page within a shopping app that describes a product offering that the user is searching for. Using this link Enabling Deep Links for App Content you'll see how to use it. And using this Test Your App Indexing Implementation how to test it. The following XML snippet shows how you might specify an intent filter in your manifest for deep linking. <activity android:name="com.example.android.GizmosActivity" android:label="@string/title_gizmos" > <intent-filter android:label="@string/filter_title_viewgizmos"> <action android:name="android.intent.a...

Android: No Activity Found To Handle Intent Error? How It Will Resolve

Answer : Add the below to your manifest: <activity android:name=".AppPreferenceActivity" android:label="@string/app_name"> <intent-filter> <action android:name="com.scytec.datamobile.vd.gui.android.AppPreferenceActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> in my case, i was sure that the action is correct, but i was passing wrong URL, i passed the website link without the http:// in it's beginning, so it caused the same issue, here is my manifest (part of it) <activity android:name=".MyBrowser" android:label="MyBrowser Activity" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="com.dsociety.activities.MyBrowser" /> <category android:name...

Android WebView Not Loading URL

Answer : Did you added the internet permission in your manifest file ? if not add the following line. <uses-permission android:name="android.permission.INTERNET"/> hope this will help you. EDIT Use the below lines. public class WebViewDemo extends Activity { private WebView webView; Activity activity ; private ProgressDialog progDailog; @SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); activity = this; progDailog = ProgressDialog.show(activity, "Loading","Please wait...", true); progDailog.setCancelable(false); webView = (WebView) findViewById(R.id.webview_compontent); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(t...

Android - GetIntent() From A Fragment

Answer : You can use a getIntent() with Fragments but you need to call getActivity() first. Something like getActivity().getIntent().getExtras().getString("image") could work. It's not that you can't pass data, it's that you don't want to. From the Fragment documentation: Often you will want one Fragment to communicate with another, for example to change the content based on a user event. All Fragment-to-Fragment communication is done through the associated Activity. Two Fragments should never communicate directly. If you take a look at the Fragment documentation, it should walk you through how to do this. If you want get intent data, you have to call Fragment's method getArguments() , which returns Bundle with extras.

Android Attaching A File To GMAIL - Can't Attach Empty File

Answer : Ok, got it to work now, after a lot of research and intercepting some Intents. What I had to do was change the file:/// to content://. I did this following this information from Android: https://developer.android.com/reference/android/support/v4/content/FileProvider.html The only major change was that I used a hard-coded path to /sdcard/file.ext. Also, the line getUriForFile(getContext(), "com.mydomain.fileprovider", newFile); was changed to Uri contentUri = FileProvider.getUriForFile(this, "com.mydomain.fileprovider", newFile); Also had to include: intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); i.setData(contentUri); I do not really understand why I had to change from File to Content , but after this, the file is now being attached again! See the link if you face this issue, and don't forget about the new .xml that needs to be created. See the following question: ...

Android: Let User Pick Image Or Video From Gallery

Answer : Pick Audio file from Gallery: //Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI); Pick Video file from Gallery: //Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); Pick Image from gallery: //Use MediaStore.Images.Media.EXTERNAL_CONTENT_URI Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Pick Media Files or images: Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/* video/*"); You start the gallery as such: Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.setType("image/* video/*"); startActivityForResult(pickIntent, IMAGE_PICKER_SELECT); then in your onActivityResult y...