Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

How get versionName package name versionCode minSdkVersion Android example

How get application version, sdk version, package name defined in the AndroidManifest file programmically Android sample.

MainClass.java onCreate()

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
			setContentView(R.layout.main);

         // in onCreate
         PackageInfo pinfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
         String sVersionCode = pinfo.versionCode; // 1
         String sVersionName = pinfo.versionName; // 1.0
         String sPackName = getPackageName(); // cz.okhelp.my_app
         int nSdkVersion = Integer.parseInt(Build.VERSION.SDK); // 7
         int nSdkVers = Build.VERSION.SDK_INT; // 7

       }



AndroidManifes.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
      package="cz.okhelp.my_app"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Add_view_to_tableActivity"
                  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>


396LW NO topic_id




AD

Další témata ....(Topics)


90

Map TreeMap get values to array Java Android example | map-treemap-get-values-to-array-java-android-example



import java.util.Map;
import java.util.TreeMap;

public class MainClass {
	public static void main(String[] arg) {

		// english;germany dictionary
		String[] arrayOfString = { "one;eine", "two;zwei", "two sets of;zwei"
				, "three;drei", "four;vier" };

		Map<String, String> map = new TreeMap<String, String>();

		for (String s : arrayOfString) {
			String[] array = s.split(";");
			String sKey = "", sValue = "";
			if (array.length > 1) {
				sKey = array[0];
				sValue = array[1];
				map.put(sKey, sValue);
			}
		}
    Object[] objectArrayOfValues = map.values().toArray();
	for (int i = 0; i < objectArrayOfValues.length; i++) {
		System.out.println(objectArrayOfValues[i]);
	}
		 
		
	}// end main

}
/*
vier
eine
drei
zwei
zwei
 */
169

Iterate HashMap getKey getValue Java Example | iterate-hashmap-getkey-getvalue-java-example



 HashMap<String,Locale> _mapOfLocale = new HashMap<String,Locale>();
    _mapOfLocale.put("French",Locale.	FRENCH	);	
    _mapOfLocale.put("German",Locale.	GERMAN	);	
    _mapOfLocale.put("Italian",Locale.	ITALIAN	);	

    for (Entry<String, Locale> entry : _mapOfLocale.entrySet()) {

       System.out.println(entry.getKey());
       System.out.println(entry.getValue());

      }



35

Android startup tutorial for developers video | android-startup-tutorial-for-developers-video


How install Android emulator on PC
//developer.android.com/sdk/installing.html

Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download