Android app crashing on startActivity ()

I started Intent and asked him to go to the main action when he tries to launch the application.

Here is the code that is trying to jump to the main action.

Intent i = new Intent( ".MAIN_ACTIVITY"); startActivity(i); 

Here is the XML manifest for Main_Activity.

 <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN_ACTIVITY" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> 

I'm still pretty new to this, so any help and / or advice is of great importance.

+4
source share
4 answers

Write like this:

 Intent i = new Intent(MainActivity.this, NewActivity.class); startActivity(i); 

You also need to declare both activity classes in the manifest file as follows:

 <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN_ACTIVITY" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".NewActivity" android:label="@string/app_name" > </activity> 
+14
source

according to your code: if I created newActiviy in my project, then:

I need to add this activity to the android manifest file.

as:

 <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN_ACTIVITY" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <activity android:name=".newActivity"></activity> </activity> 

to call this activity:

 Intent intent = new Intent(MainActivity.this, newActivity.class); startActivity(intent); 

befre ask a question here, try some search engine. and you should check this out: Creating your first Android application and Starting another activity

+1
source

For those who came from Google, I tried to pass a large string to putExtra (over 90K characters), and because of this, my application crashed. The correct solution is to either save the string to a file or implement Singleton.

Here is the link Maximum putExtra Intent Method Length? (Force close)

+1
source

Start a new activity:

 Intent intent = new Intent(YourCurrentActivity.this, TargetActivity.class); startActivity(intent); 
0
source

All Articles