Try this:
ActivityInfo ai = getPackageManager().getActivityInfo
(this.getComponentName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String value = (String)bundle.get
("org.android.androidapp.webURL");
On Feb 5, 3:34 am, Georgios Galyfos <[email protected]> wrote:
> thanks for all your replies!
>
> I think using metadata on the manifest file is the only way of doing this:
>
> I have tried to get the metadata stored in the AndroidManifest.xml
>
> My manifest file is the one below:
>
> *XML:* <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
> package="org.android.androidapp"
> android:versionCode="1"
> android:versionName="1.0.0">
> <uses-permission android:name="android.permission.INTERNET"/>
> <application android:icon="@drawable/icon" android:label=
> "@string/app_name">
> <meta-data
> android:name="org.android.androidapp.webURL"
> android:value="http://www.google.com"/>
> <activity android:name=".App"
> android:label="@string/app_name">
> <intent-filter>
> <action android:name="android.intent.action.MAIN" />
> <category android:name="android.intent.category.LAUNCHER" />
> </intent-filter>
> </activity>
> </application>
> </manifest>
>
> and the code in my onCreate() is the one below:
>
> *Java:* ComponentInfo ci = new ComponentInfo();
>
> PackageManager pm = getPackageManager();
>
> XmlResourceParser myParser = ci.loadXmlMetaData(pm,
> "org.android.androidapp.webURL");
>
> Unfortunately, the myParser value gets a null value...
>
> Does anyone know what I am doing wrong? Please help, this is urgent..
>
> I also tried the following:
>
> *Java:* Bundle b = ci.metaData;
>
> but this also returns null...
>
> Whats the correct syntax of things for me to get the metadata value (the
> webUrl stored in my metadata)
>
> any help would be highly appreciated!!
>
> On Wed, Feb 4, 2009 at 7:59 PM, Dianne Hackborn <[email protected]> wrote:
> > An .apk is really just a zip file (and a jar file too), so in theory you
> > can use any zip tools you want on it, you just need to make sure that you
> > correctly re-sign it after making changes. There is a caveat, however, that
> > aapt does a few special things to make sure to not compress certain files
> > and enforce alignment of uncompressed files for more efficient access at
> > runtime; you'll want to make sure you don't lose these things if using
> > normal zip tools.
>
> > The aapt command also has some zip-like options to add and remove files.
>
> > On Wed, Feb 4, 2009 at 9:49 AM, Georgios Galyfos <[email protected]>wrote:
>
> >> thanks for the reply, however I am trying to do this without needing to
> >> rebuild the APK..
>
> >> On Wed, Feb 4, 2009 at 7:46 PM, Mark Murphy <[email protected]>wrote:
>
> >>> Yorgos wrote:
> >>> > Do you have any other ideas of how I can store/alter information into
> >>> > the APK?
>
> >>> Simple answer: Just re-run Ant to rebuild/resign your APK after
> >>> modifying the XML.
>
> >>> More complicated answer: Tease out the specific steps from Ant that will
> >>> achieve those ends. I think you will need aapt and apkbuilder at minimum.
>
> >>> --
> >>> Mark Murphy (a Commons Guy)
> >>>http://commonsware.com
> >>> Android Training in Sweden --http://www.sotrium.com/training.php
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > [email protected]
>
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support. All such questions should be posted on public
> > forums, where I and others can see and answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---