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.

No Launcher activity found Android Emulator Error

Error: No Launcher activity found!
The launch will only sync the application package on the device!
Android emulator not showing the app
Workaround:
Check AndroidManifest.xml for MAIN and LAUNCHER. MyActivity.java is first Activity what will opened if .apk is installed.

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

396LW NO topic_id




AD

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


87

Map TreeMap key value pair sort by key, using of iterator Java Android example | map-treemap-key-value-pair-sort-by-key-using-of-iterator-java-android-example


Map TreeMap key value pair, Map sort by key, Iterator for Map Java Android example.

MainClass.java

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class MainClass {
	public static void main(String[] arg) {
		
		// english;germany dictionary
		String[] arrayOfString = { "one;eine", "two;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);
	    	}
	    }
		List sortedByKeys=new ArrayList(map.keySet());
		Collections.sort(sortedByKeys);
		
            // iterate map
	    Set references = map.keySet();
	    Iterator it = references.iterator();
	    while (it.hasNext()) {
	      String key = (String) it.next();
	      String value = map.get(key);
	      System.out.println(key + " = " + value);
	    }
            // or other example how iterate map
	    TreeSet<String> keys = new TreeSet<String>(map.keySet());
	    for (String key : keys) { 
	       String value = map.get(key);
	       System.out.println(key + " = " + value);
	       
	    }		


		
       // check if key exists 	    
//	   if( map.containsKey("two")){
//		System.out.print("two = " + map.get("two"));
//	   }
	}
}
/*
four = vier
one = eine
three = drei
two = zwei
 */
315

Ad baner without GoogleAdMobAdsSdkAndroid-6.4.1 Android example | ad-baner-without-googleadmobadssdkandroid-6-4-1-android-example


First: AdView is in XML file

<com.google.android.gms.ads.AdView
    xmlns:ads="//schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="MY_AD_UNIT_ID"
    ads:adSize="BANNER"/>

// onResume
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("TEST_DEVICE_ID")
    .build();
adView.loadAd(adRequest);




Second: Using AdView in Fragment with LinearLayout
Resolve error in ADT Graphical layout editor:
The following classes could not be instantiated:
- com.google.android.gms.ads.AdView

// layout in xml file
    <LinearLayout
        android:id="@+id/layout"
              android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

// java class with fragment in Fragment class or in Activity class
private static AdView adView;
        @Override
		public void onResume(){  
                super.onResume();
                 try {
                	 // in xml is empty layout
					adView = new AdView(getActivity());
					adView.setAdUnitId("ca-app-pub-626/638103xxxxxxx");
					adView.setAdSize(AdSize.BANNER);  
					
                	                LinearLayout layout = (LinearLayout)getView() .findViewById(R.id.layout);
					layout.addView(adView);
					
					AdRequest adRequest = new AdRequest.Builder().build();   
					adView.loadAd(adRequest);

				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
        }


More about:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration?hl=it
364

layout-sw600dp values-sw600dp Android example of use | layout-sw600dp-values-sw600dp-android-example-of-use


Why the app selects data from basic layout folder if smallest width is higher then the number in folder name?
Example 1
layout-sw600dp values-sw600dp (smallest width sw for data usage from this folder is 600dp density independent pixel!!!!!)
Device screen resolution is 1200 x 900 px (pixel) Wow, app to be select data from sw600dp folder! Realy?
DPI of device screen - dot per inch (pixel per inch) is 480 pixel it is wery important number!


  1. App selects smallest dimension of screen. In our case 900 px
    Medium screen have 160 dpi (The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen.).


  2. App calculate ratio 480 / 160 = 3 (The conversion of dp units to screen pixels: px = dp * (dpi / 160))


  3. App calculate smallest dimesnion of screen in dp 900 / 3 = 300 dip or dp (density independed pixel).


  4. App selects data from basic values and layout folder because sw600dp is greater than 300dp.





In our case smallest dimension of screen must be at least 1800 real - physical pixels (1800 px / 3 ratio(dpi/160) = 600 dp (dip density independend pixels) to be used data from folders values-sw600dp and layout-sw600dp.


Example 2 see Example 1 abouve
Device: Nexus 7 (2012) selected from Android Studio tool layout editor
Resolution: 800x1280 px
DPI: tvdpi (approximately 213dpi)
Ratio: 1.33 (213 / 160)
Smallest width in px: 800
Convert px to dp: 601.5 (800 / 1.33)
Result:Smallest width is 601.5dp The App to be used data from folders values-sw600dp and layout-sw600dp.
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