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()
AndroidManifes.xml
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)
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
*/
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());
}
How install Android emulator on PC
//developer.android.com/sdk/installing.html
Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download
//developer.android.com/sdk/installing.html
Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download
drawText(), setColor(), setTextSize(), setTextAlign()
public class ApokusActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
// CONSTRUCTOR
public SampleView(Context context) {
super(context);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.YELLOW);
paint.setTextSize(60);
//paint.setTextAlign(Paint.Align.CENTER);
canvas.drawText("Hello world!", 0, 50, paint);
}
}
}
ListFragment show only one item issue
Try to change layout_width to 0dp
Try to change layout_width to 0dp
<fragment android:name="cz.okhelp.android.fragchangfromlist.ArticleFragment"
android:id="@+id/article_fragment"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent" />
<!--todo LAYOUT_WIDTH have to be 0dp !!!!!!!!!!!!!!!!!!!!! -->
<FrameLayout android:id="@+id/article_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" />
Editace: 2011-10-08 22:19:18
Počet článků v kategorii: 396
Url:how-get-versionname-package-name-versioncode-android-example