Common Problems in Android Development

  • 2021-07-22 11:17:03
  • OfStack

This article summarizes the common problems encountered in the development of Android for everyone to learn. The specific contents are as follows

1. The problem of referencing layout in layout in Andriod (use the following method, referencing layout in layout can save resources)


<LinearLayout>
<include layout="@layout/buttom">
</LinearLayout>

2. How to judge if your mobile phone version is above 4.0
if(Android.os.Build.VERSION.SDK_INT > 10)

3. Screen switching problems and Activity restart problems
Add in the required Activity


android:screenOrientation="portrait" // The screen can only be displayed vertically 
 android:configChanges="keyboardHidden|orientation"// Guarantee when switching screens Activity Will not restart 

4. Ways to remove apk headers
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Directly added to super. onCreate (savedInstanceState); Just above

5. How to call the setting interface of mobile phone system in 5. Andriod


Intent mIntent = new Intent();
ComponentName comp = new ComponentName("com.android.settings", 
"com.android.settings.WirelessSettings");
mIntent.setComponent(comp);
mIntent.setAction("android.intent.action.VIEW");
startActivity(mIntent);

6. The method of introducing the third square package into Eclispe
Only associated with the current project: right-click on the current project- > Properties- > Andriod, click the Add button, add the A project, and then Apply

7.

Convert int type to String type
String.valueOf(int)
Convert String type to int type
Iterger.parseInt(str)

These are the common problems in the development of Andriod, and I hope it will be helpful for everyone to learn Android software programming.


Related articles: