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.

Unable to find explicit activity class Android Eclipse error


AD MOB

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.my_package/com.example.my_package.MainClass}; have you declared this activity in your AndroidManifest.xml?

Is MainClass.java in AndroidManifest as a activity ?
AndroidManifest.xml example

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
      package="com.example.my_packag"
      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=".MainClass"
                  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>

397LW 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
 */
301

sqlite database get path Android | sqlite-database-get-path-android



Context context = getApplicationContext();
String DB_PATH = "/data/data/"
                + context.getPackageName()
                + "/databases/";
18

long in java example | long-in-java-example


Android development

long is 64 bit signed type and used when int is not large enough to hold the value.

long je celé číslo 64 bitů -9223372036854775808 +9223372036854775807 a používá se tam, kde typ int není schopen pojmout takovou hodnotu čísla.


		// declaration and assignment of value type long
		long n = 22337203685477580L;
		// print formated value
		System.out.printf("The value of x is %d%n", n); // 22337203685477580
		System.out.format("%+,8d%n%n", n); // +22 337 203 685 477 580

		// declaring more variables in single statement
		long lo1 = 12L, lo2 = 56, lo3 = 1455555555589L;

		// long range of value
		System.out.println(Long.MAX_VALUE); // 9223372036854775807
		System.out.println(Long.MIN_VALUE); // -9223372036854775808

		// check if a string is a valid number in Java example
		// convert string to long Java example
		String sLong = "1288888888888888";
		long longParse = Long.parseLong(sLong);

		// convert strings to numbers
		long longFromString = (Long.valueOf(sLong)).longValue();

		// long to string in Java example code
		Long longObj = new Long(229999999999L);
		String str = longObj.toString();
		// else
		Long longS = 888888888888L;
		String strLong = longS.toString();

		// compare two long variables
		Long longComp1 = 5555L;
		if (longComp1.equals(55555555L))
			System.out.print("true");

		// compares the two specified long values in Java example

		int i = longS.compareTo(444444L); // -1 first < second
		// 0 first == second
		// 1 first > second
		System.out.print(i);
91

Class File Editor - Source not found - Change Attached Source - Eclipse | class-file-editor-source-not-found-change-attached-source-eclipse


The source attachment does not contain the source for the file TextWatcher.class.
You can change the source attachment by clicking Change Attached Source below:

You have to add JDK src.zip path to dialog as on image below.
[caption id="attachment_1091" align="alignleft" width="282" caption="class file editor source not found Eclipse warning"][/caption]



Or go to Project > Properties > Java Build Path > Libraries
Expand JRE System Library. Expand rt.jar.
Select Source attachment and double click or Edit.
Type path the source code file (External File…) and press OK.

[caption id="attachment_1094" align="alignleft" width="300" caption="Java project build path"][/caption]



Or type path in Java JRE definition



[caption id="attachment_1105" align="alignleft" width="300" caption="Java JRE deifiniton path in Eclipse"][/caption]

How open String.class or others keywords definition with Eclipse.



Now if mouse move about keywords String or F3 on keywords and press button in yellow field will opened String.class
Java Eclipse intellisense




Java-string-class-image
86

Map TreeMap key value pair add put get pair by key Java Android example | map-treemap-key-value-pair-add-put-get-pair-by-key-java-android-example


Map TreeMap add key value pair get find pair by key Java Android example.

MainClass.java

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", "three;drei" };

		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);
	    	}
	    }

       // check if key exists 	    
	   if( map.containsKey("two")){
		System.out.print("two = " + map.get("two"));
	   }
	}
}
/*
two = zwei
 */



Editace: 2014-02-15 20:46:01
Počet článků v kategorii: 397
Url:unable-to-find-explicit-activity-class-android-eclipse-error

AD
11 Share
Share
Tweet