Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

android - Make your app a default app to open a certain file

How do I make my android app the default application to open a certain file type?

I tried to clear the defaults but the option is greyed out, does anyone know how to do this?

I want to make my app open with my something.whatever files in android.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You cannot force this, and you shouldn't be able to. What you can do is make known your app can open the filetype. The user gets the standard "what program do you wish to use" dialog, and the user can select something as default. If the user has allready selected a default, he/she needs to undo that before the dialog appears (obviously, otherwise a 'default' wouldn't have a lot of effect, now would it?)

You can tell the world (aka: android) that you want to open a certain file type by adding an intent-filter. What you basically do is put in your manifest that an activity in your app knows how to handle the filetype (or website/protocol etc). That's quite easy to find, a random question here on SO about the same issue would be: Android intent filter for a particular file extension?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...