Intent intent = new Intent();
intent.setClass(MainActivity.this, Line.class);
startActivity(intent);
My cellphone alert "Sorry,The program has stopped working".
Why?
This is the error. http://www.mgiga.com.tw:8080/mo/01.jsp
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="com.sample.activity.MainActivity"
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>
</application>
Best if you could share the error you get in your logcat
Intent intent = new Intent(MainActivity.this, Line.class);
startActivity(intent);
Because your program can crash because of a lot of reasons.
Line is an Activity you haven't declare it inside manifest. Thats why you get ActivityNotFoundException.
Edit :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="com.sample.activity.MainActivity"
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="com.example.dragimagedemo.Line" >
</activity>
</application>
May be there is some problem in your second activity("Line.class") not in button click. Make another demo activity with "hello world" & check that still your app crashes or not. Example: if your demo activity named "DemoActivity" Then write code
Intent intent = new Intent(MainActivity.this, DemoActivity.class);
startActivity(intent);
If you give Logcat error then it is better understandable for us.
Edited: add activity in your manifest.xml
<activity
android:name="YourPackageName.Line"
android:label="#string/app_name">
Try this way,hope this will help you to solve your problem.
Intent intent = new Intent();
intent.setClass(MainActivity.this, "YourPackageName.Line");
startActivity(intent);
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".MainActivity"
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=".Line"/>
</application>
</manifest>
Related
So I have 2 ways an activity can be opened. One is from the activity flow of:
Main > Tracks > Day > Topic > TrackSelect > TrackInfo
and the other is:
Main > MySchedule > TrackInfo
If I try to get TrackInfo to open up via the second path, it crashes the app.
However, If I go from the first path, then all the way back to the main, then through the second path, it works perfectly. Is there something weird going on?
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fayko.conference_app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="Conference-App"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".mainSelection"
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=".topicScreen"/>
<activity
android:name=".myScheduleScreen" />
<activity android:name=".trackSelection" />
<activity android:name=".mainScreen" />
<activity android:name=".daySelection" />
<activity android:name=".trackInfoScreen" />
<activity android:name=".mapChoose" />
<activity android:name=".sponsorScreen" />
<activity android:name=".committeeScreen" />
<activity android:name=".welcomeScreen"></activity>
</application>
</manifest>
Code from TrackSelect > Track Info:
Intent intent = new Intent(trackSelection.this,trackInfoScreen.class);
startActivity(intent);
Code from MySchedule > TrackInfo:
Intent intent = new Intent(myScheduleScreen.this,trackInfoScreen.class);
startActivity(intent);
I appreciate any help you guys can give me.
It turns out that the issue I was having was due to some internal code. Even thought he stacktrace was saying things about socket lost for the debugger.
when I update my SDK the icon app doesn't appear in the activities I tried all the solution on the internet but nothing happened .. I tried also to put " android:icon" in each activities nothing change also made a custom actionbar also nothing change .. please any help?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=""
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
"
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme" >
<activity
android:name=".Main"
android:label="#string/app_name"
android:theme="#style/NoActionBarTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Option"
android:label="#string/title_activity_option" >
</activity>
<activity
android:name=".CustomList"
android:label="#string/title_activity_custom_list" >
</activity>
<activity
android:name=".Social"
android:label="#string/title_activity_social" >
</activity>
<activity
android:name=".About"
android:label="#string/title_activity_about" >
</activity>
<activity
android:name=".ActionBar"
android:label="#string/title_activity_action_bar" >
</activity>
</application>
</manifest>
Hi there basically i have created a options menu and have one of the menu items as the home button which essentially calls the home activity Main.java. I have used the code
startActivity(new Intent("org.me.myandroidstuff.Main"));
in a GetHome method. My problem is that when i run this the application crashes because it isnt handled. Now i know this generally means there is some error in the androidmanifest file however i think my coding is okay so im a bit stumped. Here is my androidmanifest.xml code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.me.myandroidstuff"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:allowBackup="false">
**<activity
android:name=".Main"
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=".PetrolPriceActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="org.me.myandroidstuff.PetrolPriceActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".AreaURL"
android:label="#string/app_name" >
<intent-filter>
<action android:name="org.me.myandroidstuff.AreaURL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
the part highlighted is the code for my main class. Im rather new to android so i imagine its a relatively simple fix but ive looked and i havent found a solution yet. Thanks
change the code to
startActivity(new Intent("android.intent.action.MAIN"));
In manifest file in action you have written
< action android:name="android.intent.action.MAIN" />
while calling the new Intent(String Action), you need to put the same action name.
or you can use different signature of constructor,
change the code to
startActivity(new Intent(this, Main.class);
in place of "this" you can use the appropriate context.
use startActivity(new Intent(getApplicationContext(), Main.class));
I need a hand with the Android Manifest file.
I have 4 java files called: MainActivity, Splash, TextPlay and Menu. I want the Splash file to be displayed first. (I have it set for 5 seconds)
I then want the Menu to be displayed(I have the rest of the files displayed on Menu page.)
The app also wont debug on the emulator and im guessing its the manifests fault.
Can someone help me achieve this, Thanks!!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intigerdev.numberapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.intigerdev.numberapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MENU" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TextPlay"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
You will have to move between activities on your own. The manifest doesn't do that for you.. if you want your app to start on the Splash screen use this manifest instead:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intigerdev.numberapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
<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=".Menu"
android:label="#string/app_name"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name"/>
<activity
android:name=".TextPlay"
android:label="#string/app_name"/>
</application>
</manifest>
OnCreate of the Splash activity (stackoverflow.com/a/6489385/736496):
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
finish();
Intent intent = new Intent(Splash.this, Menu.class);
startActivity(intent);
}
}, 5000);
}
The title explains it pretty much, here is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.craym.vulcrum.firstgametnb"
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=".StartingPoint"
android:label="#string/app_name" >
<intent-filter>
<action android:name="eu.craym.vulcrum.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Yet whenever I run this application, the StartingPoint classed is called first:
[2013-03-09 18:36:40 - FirstGameTNB] Starting activity eu.craym.vulcrum.firstgametnb.StartingPoint on device emulator-5554
Why is this happening? I thought the MAIN and LAUNCHER were supposed to make it so the Splash class gets called first, but this never happens. Note that when I delete the StartingPoint activity, it goes to Splash.
You're right. You may try a clean on your project.
android.intent.action.MAIN: Start as a main entry point, does not
expect to receive data.
Source