Launching a pdf asset from android menu? - android

I have included a file called "Manual.pdf" in my assets folder. I have created a menu button called "Help". I want the user to be able to go to the menu, press on the Help button, and launch the Manual.pdf file in whatever viewer the phone has installed.
I have read for a few hours on this site and other sites, but I just can't get the file to launch.
Thanks for any help.

There is no unified PDF reader for Android Devices. I assume that in the course of your research you would have found that, you could use an implicit intent to invoke a pdf reader if it does exists.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
intent.setType("application/pdf");
It works in some devices and fails in some other devices. ( so please check availability of intent using the package manager). If you are targeting a particular device then you could get the corresponding Activity Object and use an Implicit Intent.(com.htc.pdfreader for HTC Phones).

Related

Storage access framework/Document tree Shows Empty Recent List

I am using Storage access framework to make the user grant write permission for Sd card. It is working fine with two of my devices running on Android lollipop and Marshmallow. But it it not working with One of my device running on Android lollipop.
It is showing empty recent list.
Screenshot
This is how I am starting the activity
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, 42);
I tried using the menu button but it was of no use.
Is there any workaround to make the user grant write permission/Add Sd card directory to recent list? Because it is working for a couple of other apps such as ES Explorer.
Solved it by adding an Extra to the Document Tree intent.
Intent intent=new Intent("android.intent.action.OPEN_DOCUMENT_TREE");
intent.putExtra("android.content.extra.SHOW_ADVANCED",true);
startActivityForResult(intent,42);

How can i open .doc and ms office files in quickoffice without using filechooser in android?

How can I open .doc and ms office files in quickoffice in android without using filechooser.
First of all, I think your problem is that if there are more than one application the user gets the option to select the app he wants to use.
You should not interfere with that. That's how the system is designed and how it should work. But if you really have to, you can use the full qualified name of the Activity Quickoffice uses as hook in their AndroidManifest.
For that you can look into their APK and check the manifest.
But again: That's not how it should be done.
Bad practice. Very, very bad practice!
It worked for me. I could able to get launcher activity by using Packagename for getLaunchIntentForPackage method.
PackageManager packageManager = getPackageManager();
Intent quickOffice = packageManager.getLaunchIntentForPackage("com.quickoffice.android");
startActivity(quickOffice);

Change Wallpaper intent Application crashes in Nook Color:

I need to develop a Wallpaper application for Nook Color. I have installed the Nook color addon after that when i use this code in my app and it gets crashed every time. The below API Intent to allow any application to open the Wallpaper Settings Manager UI in Nook Color device
Intent i = new Intent();
i.setAction( "com.bn.nook.CHANGE_WALLPAPER" );
startActivity( i );
Error: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.bn.nook.CHANGE_WALLPAPER }
Please help, Thanks in advance.
This intent is only going to be available on Nook device.
Using this on any other device or emulator that isn't specifically designed to be the nook isn't going to work.
It would be like trying to open Internet Explorer on a machine which doesn't have Internet Explorer installed.
The code you have posted is a direct copy paste from (i assume) the official Nook Developer page here.
The code isn't inherently wrong, the Action your specifying simply doesn't seem to exist - you need to find the correct Action name from the Developers/Nook API.

Launching Android Market Main Page from an application

I'm trying to write a launcher-like application (I'm not planning to release it, it's just for me to use) but I don't seem to find any way to launch the Market.
All of the answers I've found actually perform a search on the Market (using a uri "market://") or even worse they run the Market on a specific app page, while I'm trying to show the main page of the Market, i.e. the page shown when you run it from the launcher.
I tried using just "market://" as a Uri, without query strings, but it doesn't work; I also tried to get exactly the same "signature" of the "start activity command" that appears in the LogCat when I run the Market from the Launcher (by manually editing component, flags and categories), but it still doesn't work.
Is there any way to get it to show the main page?
Thanks in anticipation.
Intent intent = new Intent();
intent.setClassName("com.android.vending", "com.android.vending.AssetBrowserActivity");
startActivity(intent);

Android open source activity to let the user select/create a media?

In my open source app, I want to let users insert a picture/video/sound/etc. The user can either select an existing media from the SD card or use the device's hardware (take a photo, record a video, record a sound, draw on touchscreen) if they prefer to create a new media.
There are plenty of code snippets showing how to implement each of these things, but rather than re-inventing the wheel, is there a library that handles the whole activity of choosing a media file? I would just call this library, it would handle the UI, and return me the filepath to the media the user selected/created.
Here is how it could look like:
I am sure many apps would find this widget useful (CMS authoring, wysiwyg, sharing apps, rich chat, ...). As an LGPL (or public domain) component, I am sure it would be popular and gather a community of developers. Before I launch this project, is there already such a gadget?
I wrote a small Android Library Project, called aFileChooser, that aims to streamline the selection part of this process. It includes a built-in file explorer, and returns a File object after selection. You can also retrieve the image or video thumbnail, and use helper methods to get the URI and path.
Disclaimer: I haven't had a chance to test this with ICS, but it should function properly.
https://github.com/iPaulPro/aFileChooser
Finding an all-in-one solution with capture may not be as easy, as this is one of the areas where fragmentation is real.
For taking a picture, use this Intent:
Intent intent = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
startActivityForResult(intent);
For taking video, use this Intent:
Intent intent = new Intent( android.provider.MediaStore.ACTION_VIDEO_CAPTURE );
startActivityForResult(intent);
For recording audio, use this Intent:
Intent intent = new Intent( android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION );
startActivityForResult( intent );
You, of course, would have to design the Activity to pick which action they would like to perform. See the linked documentation for retrieving the file path when the Activity returns.
OI File Manager for Android is an open file manager that seamlessly cooperates with other applications http://www.openintents.org/en/node/159

Categories

Resources