I want to have a normal class file in my android package that is not a component but will be used by an activity. Is this allowed? How do I add this in the manifest if required?
Right now it is not part of my manifest and I am getting an 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED' error in my Android project and don't know if it's because of this generic class file.
Thanks
Is this allowed?
Yes.
How do I add this in the manifest if required?
You don't put it in the manifest.
It's not needed to add to the manifest. You can have as many "normal classes" as you wish (by normal i suppose that are classes that do not extend activity).
Take a lot at LogCat during install to check what the problem is.
Related
I am trying to implement Android N shortcuts but it crashes with an exception
android.content.ActivityNotFoundException: Shortcut could not be started. I believe its because I am not giving the correct targetPackageName in shortcuts.xml
I am not really sure what it should be pointing to if the application itself is in a different module and the activity I am trying to start is in a different module.
Any help is appreciated.
I had a similar problem recently. For me, the issue was that the Activity I was trying to launch only had an intent-filter for the LAUNCHER category. Once I created a separate intent filter that had category DEFAULT (ie, category android:name="android.intent.category.DEFAULT"), everything worked fine.
Note that if you're trying to use activities from different modules, it may be more flexible to use implicit intents. While your original approach will still work just fine, you may want to consider moving to using action constants instead of referring to the package name.
If that doesn't fix your problem, can you post your manifest and your shortcuts.xml?
Be sure TargetPackageName is Correct. Use package name where activity exist.
Use ActivityName like this:
android:targetClass="com.example.logs.ExampleActivity"
Use Package like this:
android:targetPackage="com.example.logs"
I Hope this works!!!
I'm writing an SDK and would like developers to be able to create an activity-alias whose targetActivity is set to an activity inside my SDK. I'm doing this because I'd like them to be able to customize the intent filter on a specific activity in the SDK. If in the sdk's manifest there is ActivityX, I'd like them to be able to write an activity-alias like this in their app's manifest:
<activity-alias
android:name="abc"
android:targetActivity="ActivityX">
<intent-filter>
... user's custom intent filter
</intent-filter>
</activity-alias>
The problem I'm coming across is that the targetActivity has the restriction that it:
"... must match the name attribute of an activity element that
precedes the alias in the manifest."
This is a problem because no matter where I place the activity in the sdk's manifest or where I place the alias in an example app's manifest, the alias always comes before the activity in the final merged manifest causing an INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error.
One idea is to put an alias without an intent filter just after ActivityX is declared in the sdk manifest and hope that the two aliases will be merged together and stay in the sdk alias's position. But I can't figure out how to do that. One reason that might not be working is that two aliases may not be able to conflict.
Do you have thoughts on solving this via a merge solution or some other technique?
An identical issue was brought up in the AOSP. A workaround to the problem is described there as follows:
Manually include the manifest entry for the Activity from [the sdk] in
the manifest of the application project, placing it before the
activity-alias entry.
Despite the fact that this workaround has the problem of
... duplicate code across manifests.
it seems that the project maintainers deemed this solution as adequate. There is no indication that a fix to the underlying problem will be released any time soon.
I have created a library module that is working when I add the permissions and activity tags to every project's manifest that uses it.
I'd like to encapsulate it as much as possible, is there any support for exporting a library's manifest tags so that I, and others can skip this step?
http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject alludes to 'no'.
Have you tried setting the manifestmerger property to true. See this question.
I need to include 2 Android projects extending Application class as library project in my project. Android manifest allows to make only 1 android:name= in manifest file.
Please advice me the best practice to get it done.
Looking forward for tips & Suggestions.
rohit
So finally I got it work. What I did is let the android:name= as it is in Application of AndroidManifest.xml and in the other application, i used getApplication() of Activity
http://developer.android.com/reference/android/app/Activity.html#getApplication()
While writing Android manifest some configuration I must put inside "application" section (eg. list of activities) and some outside it (eg. uses-sdk). Why? Is there any general rule what goes inside "application" section and what outside? Or was it pure random arbitrary decision by Android creators?
Not really a programming question. If you follow commit history of AOSP you might get an answer. Or track down Andy Rubin and ask him :)
With the current layout, you could theoretically have multiple applications inside the same APK. Stuff that is common to all applications will got at the highest level (uses-sdk, etc.), everything else inside the corresponding <application>.
Definitely it is not a random decision.
The Format is something like you have define the configurations pertaining to any application such as its activities and services inside tag because ofcourse they are related to your application.
And General libraries you use and Permissions outside of the tag which complement your application.
Take a note of the structure of the manifest file here
To get concept in detail try here.