My application is trying to open a text file, and is presented with a list of apps that are able to open the text file, for eg (HTMLViewer, OpenOffice, etc). I want my application to open text file via OpenOffice automatically, without the list dialog popping out. Is there any ways to do that programmatically?
NOTE: This question is assuming that the user has the necessary applications installed and the applications mentioned in this question only serve as examples.
What you are looking for is setPackage()
Set an explicit application package name that limits the components this Intent will resolve to. If left to the default value of null, all components in all applications will considered. If non-null, the Intent can only match the components in the given application package.
Related
I would like to add support to different languages in my app. As I understand, Android uses the proper strings.xml file according to the operation languages of the device. But what If I want to allow users to change the language in the settings? What steps should I do? I thought of keeping the the user's language in the his document (Firebase cloud) but then if the user if logs out the app, the main page (login/sign up) will be in the default language (and not in his language).
I guess that there is a proper "flow" that I need to follow in order to add support to multi languages. Is it possible to share this flow with me?
you can go to res- values, then from the right click list create a new Values Resource File
from the window appears name the files strings and then select locale and add your language or country.. picture below to make it clear for you
then after that you can change the locale programmatically using these methods and let android system do the rest of work
I am very new for developing the multi-language oriented Android APP. This is the first time i am going to support my app in multi-support language app. I need some clarification for developing the multi-language support app. Already i have some ideas before initiate the development.
Single APK with Localization like will make the multiple String.xml and include it in inside of the app and based the member selection of language its automatically invokes and works.
All language strings values will retain in app server (back-end) and will raise the Rest-API request and get those values and change it inside of the entire app (all screens) if member click and change the language inside of the app.
Main concern is if anything needs to change in future then Idea2 is best way. We will just change in back-end side it will be appeared in client side. But if we are going Idea1 and wants to change then we need to put the new build only.
Which one is best approach and recommended way to develop?
You will need to create different String.xml depending the languages you want to target as JDenais says, in my app i have the following
for example the first arab string consist in the same as Strings.xml but with all in arab, now, you only need to call one string in your xml files and it will just select where to grab depending on the phone language. Or in default the language from where the app was downloaded by google play, in fact, they are all the same strings.xml , so you dont need to specify which one you want to pull the translated text from, just replicate your main strings.xml in your other strings.xml and then the phone will decide where to pull the data.
Also please read the official doc on how to accomplish this https://developer.android.com/training/basics/supporting-devices/languages
Also please check the language ISO Codes here
What is the list of supported languages/locales on Android?
All your texts should be packaged in the APK in different String.xml files. Forget about receiving texts from a backend. It would be a lot of extra work for limited gain and with added risks of failure.
The framework takes care of selecting the appropriate string.xml file and offers support for needed use cases like plurals.
right click the values folder and choose new-> values resource file -> locale -> choose the language you want and name it strings.
copy the strings from the original string file to the new file and change them to the new language just the strings
make sure that the view xml files have their text set as "#string/the_name of the string" not hard coded
In Android Live Wallpapers, the usual Android View classes cannot be used (as far as I know). Therefore, if you want to let a user select a file, you would have to write your own File Chooser interface pixel by pixel. This would be an extraordinary endeavor.
Is there any way for users to pass a parameter -- such as a file name or directory location -- to an Android application?
Live Wallpapers have a mechanism to have a settings UI associated with them that can be set when the user is selecting the wallpaper. This is android:settingsActivity described here: http://developer.android.com/reference/android/R.styleable.html#Wallpaper
You might consider using Open Intents. For example, apps like OI File Manager offer intents like PICK_FILE that let other app developers use their functionality. Installing may add several clicks the first time but it's otherwise fairly seamless (just like choosing an attachment from Gmail).
Check out:
Open Intents: Pick Folder
Open Intents: Pick File
Hi
I created an application (BookReader) that parses and displays a certain book (given as the default book).
But if I simply copy any other book on my device and attempt to open it, android displays a list of suggested installed applications that can open my book. Among these suggested applications is my app (BookReader) too and if selected it opens that book.
How can set my app so it won't appear in the suggested android apps list? Because I don't want my app to be used for opening other books. Just the default one.
Thanks
NOTE! I want it to appear in the application list. I just don't want to appear as a app suggestion for opening other books or files.
thanks guys!
I solved it by removing the mimeTypes in the manifest file which were inside the intent-filter that was a match for the action of opening those file formats.
Hope this helps others too
Your application is probably registering for an intent that matches the intent used by any book. You probably want to modify your IntentFilter to narrow the scope to only match your specific book somehow. What intent does your book generate?
You will need to modify the AndroidManifest.xml to remove the IntentFilter that listens for books. If you paste the contents of this file, I can provide more exact details.
Did you take an open source eBook reader and try to package individual books as their own applications?
I'm a new in Android and Java and I have the following problem. I want to change standard resources, such as button background, programatically to allow applications using standard buttons be displayed with custom background. My problem is - how shall I identify the path for retrieval resources on phone or emulator? And if we have permissions to access to those resources?
The only way you can change "standard resources" for the entire device is to modify and install your own firmware.