I'm porting an application to SDK 3.0.
I have already modified the Settings to use the new Fragment feature available in PreferenceActivity.
The problem I have now is that the following configuration I had in the settings.xml does not work any more:
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="#string/mykey"
android:summary="#string/musummary"
android:title="#string/mytitle" >
<intent
android:action="android.intent.action.MAIN"
android:targetClass="com.android.settings.WirelessSettings"
android:targetPackage="com.android.settings" />
</PreferenceScreen>
com.android.settings.WirelessSettings is not found. Do you know why?
My first guess is that now that activity does not exist any more and was replaced by a fragment.
The problem is that I can't find how to call this fragment.
Do you know how to embed the standard WirelessSettings Fragment in my application?
Thank you
OK finally I found the correct version. This works:
<intent
android:action="android.settings.WIRELESS_SETTINGS"/>
com.android.settings.WirelessSettings is not found. Do you know why?
They either elected to rename the class or make it be not exported. You should not have been using this in the first place -- any references to com.android are a really bad idea, as they are not part of the Android SDK.
Do you know how to embed the standard WirelessSettings Fragment in my application?
You can't embed fragments from other applications in your own application.
I have also tried: with that intent I get: android.content.ActivityNotFoundException: No Activity found to handle Intent {...
I can tell you that this works on a XOOM:
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
Your action string is wrong -- replace settings.Settings with just Settings. Try that and see if it helps. If not, perhaps there is something peculiar about using <intent> in preference XML -- I've never used it. Regardless, Settings.ACTION_WIFI_SETTINGS is the proper way to refer to this particular portion of Settings.
Related
We know that xml layout code gets parsed to java view object in setContentView call. But I was just curious to know when are the manifest properties (like windowSoftInputMode, screenOrientation etc) are applied to the activity. I mean what lifecycle method?
Any practical explanation is more than appreciated, TIA!
Well, I think manifest will get attached to the app in its installation period. like when we start installing an app , it will read its manifest file to check ;
where to install
What permissions to show
which activity is a launcher for the app
for more information:
https://developer.android.com/guide/topics/manifest/manifest-intro
I'm puzzled about how to use WindowManagerPreference:FreeformWindowSize and WindowManagerPreference:FreeformWindowOrientation mentioned in the official Android on ChromeOS guide.
When I use it, it seems like the window is always maximized, e.g. if I set it up like this:
<meta-data android:name="WindowManagerPreference:FreeformWindowSize"
android:value="phone" />
<meta-data android:name="WindowManagerPreference:FreeformWindowOrientation"
android:value="portrait" />
If I at the same time specify layout for an activity and starts it directly, the window is not maximized anymore.
Does anyone know how the two meta tags can be used? When I google them, the only results is the guide mentioned above and a few other projects using them.
I am seeing the same. Adding these parameters seems to have no effect on Chrome OS.
Answer for a Xamarin context, and with a different meta data option. (Although technique should work for all development environments)
Note the metadata needs to be under the Activity element in the AndroidManifest.xml
Using C#/Xamarin one can add the MetaDataAttribute to main Activity.
[MetaData("WindowManagerPreference:SuppressWindowControlNavigationButton", Value = "true")]
[Activity(Label =...
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
This removes the backbutton from android apps running on chromeos, but has no effect on android apps running on android devices.
When I create a "New Android Application Project," I would like Eclipse to proceed with its normal actions with (at least) one customization.
I want Eclipse to create the new Activity.Class file using fuller #Overrides rather than just the onCreate(), such as also providing onStart(), onResume(), onPause(), onRestart(), and so on.
In other words, I want a more verbose Activity.Class file generated than is already done by Eclipse.
Going further, I would also like Eclipse to add my own inner classes - if that is not asking too much.
In short, is there a template in Eclipse that I can tailor for this customization?
I am not aware of a way to accomplish this within the "New Android Application Project Dialog", but you add additional overrides to each activity yourself by clicking the Source dropdown menu, then Override/Implement methods..., and then select each method you would like to override.
I'm not sure what you mean by add your own inner classes. You can do this easily yourself, I'm not sure what additional functionality Eclipse could provide.
This might answer your question. There's a templates directory in your Android SDK where you can add or alter the XML templates.
Good luck,
Bp
I add new class in the android/packages/apps/phone/src and I want to call the class in the ohter application.
Assume that the new class is SS.java
I added
<activity android:name="SS"></activity>
in the AndroidManifest.xml file in the android/packages/apps/phone folder.
The application which want to call the SS class has a list and I put the code in the xml file;
<PreferenceScreen
android:title="#string/SS">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.phone"
android:targetClass="com.android.phone.SS" />
When I choose the menu in the list, the phone show Class Not Found Exception.
The message isUnable to find explicit activity class {com.android.phone/com/android.phone.SS}; ....
Please let mw know what is the problem
Are you talking about contributing to the AOSP or building custom ROMs? If you are, this is not the most relevant forum. Try http://groups.google.com/group/android-contrib?pli=1.
If you are not, then:
The android/packages/apps/phone is a part of special apps shipped with the OS. You can't add classes to this package. Even if you do and compile the AOSP code, no phone will have your classes, so no application can use your classes.
I want to open an activity without declaring it in an manifest file.
I don't know if it is possible or not.
What I actually want is to dynamically open an activity from my program using intents.
Can anyone help me if it is possible.
Not possible. Although I am unsure what you mean "dynamically open an activity".
See: http://developer.android.com/reference/android/app/Activity.html
Under Class Overview it states "To be of use with Context.startActivity(), all activity classes must have a corresponding declaration in their package's AndroidManifest.xml"
You can have an Activity in your package and not define it in the manifest, however you would not be able to start it successfully.
Your 'Dynamic' activity start is actually the normal way of starting an activity (as you have said in a comment to the answer of Matt M). Though you HAVE to add the Activities in manifest as Matt M said. In list view, clicking an activity will call a function that will start respective activity with startActivity() function.
I tried this very long, but since the Instrumentation class uses the IActivityTaskManager, which is a class of the internal API located at com.android.server.wm, that is not in the Activity classloader, I solved this by another method:
Using a subclass
I just made an Gist, with sample code.
GIST