This is the android manifest:
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="11" />
<application
android:allowBackup="true"
android:icon="#drawable/pic"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.thenewboaton.travis.abc"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.thenewboaton.traivs.splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboaton.Splash" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
The Main java class named MainActivity:
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
int counter;
Button add;
Button sub;
TextView display;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
counter=0;
add=(Button)findViewById(R.id.bAdd);
sub=(Button)findViewById(R.id.bSub);
display=(TextView)findViewById(R.id.tvDisplay);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
counter++;
display.setText("Your total is "+counter);
}
});
sub.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
counter--;
display.setText("Your total is "+counter);
}
});
}//method
}//class
Finally the logcat:
06-17 18:51:51.427: E/AndroidRuntime(358): FATAL EXCEPTION: main
06-17 18:51:51.427: E/AndroidRuntime(358): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.thenewboaton.travis/com.thenewboaton.travis.abc}: java.lang.ClassNotFoundException: com.thenewboaton.travis.abc in loader dalvik.system.PathClassLoader[/data/app/com.thenewboaton.travis-1.apk]
06-17 18:51:51.427: E/AndroidRuntime(358): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
so i tried varying the class names here and there and also the activity name. As soon as the emulator starts the error comes saying the Launcher has failed and the app doesn't start off at all .. i cant remember the EXACT change i did before this error started ..
anyone can help me out on this ?
I'd be glad if anyone can figure this out . thanks :)
You need to point the AndroidManifest at MainActivity:
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Or, if you Activity is called abc or splash, and is located in your main package, you can use:
<activity
android:name=".abc"
android:label="#string/app_name" >
...
</activity>
and
<activity
android:name=".splash"
android:label="#string/app_name" >
...
</activity>
Your manifest points to two activities: "abc" and "splash" but your source code is called MainActivity. Either renmae MainActivity to abc or edit the manifest to point to MainActivity instead of abc.
Related
Is it possible to open a FragmentActivity after Splash screen?
I want to open the FragmentActivity / Fragment after the Splash screen but I get following Error:
Unable to find explicit activity class {com.**********.MainActivity};
have you declared this activity in your AndroidManifest.xml?
My splash screen:
public class SplashScreen extends Activity {
private final int SPLASH_DISPLAY_LENGTH = 3000;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable(){
#Override
public void run() {
Intent mainIntent = new Intent(SplashScreen.this,Juli.class);
SplashScreen.this.startActivity(mainIntent);
SplashScreen.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
}
Manifest:
<activity
android:name="com.test.tab.SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In Manifest add:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<!-- Splash screen -->
<activity
android:name="com.test.tab.SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main activity -->
<activity
android:name="com.test.tab.Juli"
android:label="#string/app_name" >
</activity>
</application>
Friends,
I Have created an android file in eclipse and Exported as an android file. When i install it i got two android files. I have two java files in the app. one is second.java and the other is first.java.
When i install the app in blue stacks , it installed two files . One is first and other is second.
I have a button in my first.java which goes to the second.java file. How can i solve it by installing only one app in app tray...???
Here is my code
first.java
package com.zacter;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class first extends Activity {
Button button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addListenerOnButton();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void addListenerOnButton(){
final Context context=this;
button=(Button) findViewById(R.id.continuebutton);
button.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
Intent intent = new Intent(context,second.class);
startActivity(intent);
}
});
}
}
Second.java
package com.zacter;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class second extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_boostram);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.boostram, menu);
return true;
}
}
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zacter"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.zacter.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.zacter.SettingsActivity"
android:label="#string/title_activity_settings"
android:parentActivityName="android.app.LauncherActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.app.LauncherActivity" />
</activity>
<activity
android:name="com.zacter.Boostram"
android:label="#string/title_activity_boostram" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Replace 'LAUNCHER' with 'DEFAULT'
See here for further explaination
In your manifest files, you are having more than one activities with the intent filter category as launcher.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The intent category means you are going to have two launcher icons, or two launch points for your application.
You can read more about it here
http://developer.android.com/guide/topics/manifest/category-element.html
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zacter"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.zacter.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.zacter.SettingsActivity"
android:label="#string/title_activity_settings"
android:parentActivityName="android.app.LauncherActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.app.LauncherActivity" />
</activity>
<activity
android:name="com.zacter.Boostram"
android:label="#string/title_activity_boostram" >
</activity>
</application>
</manifest>
just Because of these lines.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
keep this intent filter for only one activity which you want to launch at starting. if you keep category launcher for any other activities it will creates multiple launcher icons in applications. for more details check this link here
Keep this tag in only first activity remove from Boostram activity tag
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<category android:name="android.intent.category.LAUNCHER" /> will create launcher activity, so if you have multiple LAUNCHER category in AndroidManifest.xml file, multiple launcher activity will generate.
Modify your AndroidManifest.xml like below.
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".first"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".second"
android:label="#string/title_activity_main" >
</activity>
</application>
I want to run an implicitly tried with the following code:
MenuActivity.java
public class MenuActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
Button btn = (Button) findViewById(R.id.btnVideo);
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri intentUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.pp);
intent.setDataAndType(intentUri,"audio/mp3");
startActivity(intent);
}
});
}
}
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/iconopp14"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.powerpump.MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MenuActivity" />
</application>
You need to specify more parameters in AndroidManifest.xml?
Thanks.
I guess you simply have to register your MenuActivity in you AndroidManifest.xml as demonstrated here.
Looking at your code, it looks like you created a MenuActivity class after creating an android project with default settings and MenuActivity is your main activity(Launcher) class.
Just replace the MainActivity with MenuActivity in your AndroidManifest.xml file and delete
<activity android:name=".MenuActivity" />
OR
Replace the class name to MainActivity from MenuActivity in your java code as follows
public class MainActivity extends Activity {
......
OR
use this as your android manifest.xml file
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/iconopp14"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name="com.powerpump.MenuActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I'm trying to start an activity
`package com.kapzlock.mytestproject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity{
#Override
protected void onCreate(Bundle SomeVar) {
// TODO Auto-generated method stub
super.onCreate(SomeVar);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
}
catch(InterruptedException e){
e.printStackTrace();
}
finally{
Intent openStartingPoint = new Intent("com.kapzlock.mytestproject.MAINACTIVITY");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
`
The Manifest xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kapzlock.mytestproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.kapzlock.mytestproject.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
It compiles without problems, but when I run the Splash.class, I'm getting an Exception in thread "main" java.lang.NoClassDefFoundError: android/app/Activity Error. The package name is com.kapzlock.mytestproject and the class that I'm referencing to is MainActivity.class. Has anybody an idea where the mistake could be in?
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes.Click on Apply and clean the project.
This worked for me.Hope this helps.
Replace your code with following
finally
{
Intent openStartingPoint = new Intent(this,MAINACTIVITY.class);
startActivity(openStartingPoint);
}
Remove following from your manifest.xml in mainActivity tag
<intent-filter>
<action android:name="com.kapzlock.mytestproject.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
I'm trying to play an video on my android app, but when I click on the activity through my menu list, the app stays on the list and doesn't play the video.
The code is below
my menu
package com.example.taekwondobuddy.util;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Kicks extends ListActivity {
String classes[] = {"FrontKick","RoundhouseKick","AxeKick"} ;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Kicks.this, android.R.layout.simple_list_item_1, classes));
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String cheese = classes[position];
try{
Class ourclass = Class.forName("com.example.taekwondobuddy.util" + cheese);
Intent ourIntent = new Intent(Kicks.this, ourclass);
startActivity(ourIntent);
} catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
the video I'm trying to play
package com.example.taekwondobuddy.util;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class RoundhouseKick extends Activity {
private VideoView mVideoView;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.roundhousekick);
mVideoView = (VideoView) findViewById(R.id.roundhousekick);
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() +"/"+R.raw.roundhousekick));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
the xml layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="#+id/roundhousekick"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
and the manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.taekwondobuddy.util"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.taekwondobuddy.util.Menu"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.taekwondobuddy.util.Tools"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.taekwondobuddy.util.Techniques"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.taekwondobuddy.util.Kicks"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.example.taekwondobuddy.util.Counter"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.example.taekwondobuddy.util.Time"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.example.taekwondobuddy.util.Accelermeter"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.example.taekwondobuddy.util.FrontKick"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.example.taekwondobuddy.util.RoundhouseKick"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.example.taekwondobuddy.util.AxeKick"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
</activity>
</application>
</manifest>
I think it something wrong with the manifest but I can't really see what's wrong, any ideas? Plus the video are in mp4 so they're are in the right format for android
I think, you just missed one little thing: a dot (.)
See at your code here:
Class ourclass = Class.forName("com.example.taekwondobuddy.util" + cheese);
don't you think it should be like this:
Class ourclass = Class.forName("com.example.taekwondobuddy.util." + cheese);
Try to use:
mVideoView.start();