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.

The application may be doing too much work on its main thread

Warning: The application may be doing too much work on its main thread
Try this sorce code:

import android.os.StrictMode;

public class MyActivity extends Activity {
		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    public void onCreate(Bundle savedInstanceState) {
//.................. etc.

396LW NO topic_id


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


How add Android code templates to Eclipse | how-add-android-code-templates-to-eclipse

If you have to type frequently the same code you can create templates which can be activate via autocomplete with Ctrl + Space.

For example lets assume setOnClickListener body.

To create a template for this select the menu Window->Preferences and Open Java -> Editor -> Templates


Type name of template in Eclipse s editor and pres Ctrl+Space

[caption id="attachment_1114" align="alignleft" width="300" caption="Eclipse-show-template-proposals"]android/eclipse-show-template-proposals-300x222.png[/caption]

Select your template from intellisense help and press Enter or double click on selected item.

[caption id="attachment_1116" align="alignleft" width="300" caption="Eclipse - select your template"]android/eclipse-show-template-proposals-2-300x187.png[/caption]

	mIdButtonHome.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Intent browserIntent = new Intent(Intent.ACTION_VIEW,

Quick help in Eclipse editor: select keyword and press Ctrl+1


Shuffle Array of String Java Example | shuffle-array-of-string-java-example

       String[] sAr = new String[] {"one","two","three"};
       List<String> wordList = Arrays.asList(sAr);
       Collections.shuffle( wordList);
       String[]myShuffledArray = wordList.toArray(new String[wordList.size()]);


How to Add Home Screen Widgets on Your Android Phone | how-to-add-home-screen-widgets-on-your-android-phone

Long press by finger on screen
From dialogue select Widgets
Select your widget
Put your widget on the screen

Video tutorial - to add home screen widgets - Android 2.1