I tried cleaning up and rebuild the project but none of them worked
next.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
viewPager.setCurrentItem(mCurrentpage+1);
if (mCurrentpage == mDots.length-1) {
Intent login = new Intent(OnBoardingActivity.this,LoginActivity.class); //*showing unable to find class LoginActivity*
startActivity(login);
}
}
});
Here is my AndroidManifest.xml
<activity android:name=".OnBoardingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You need to add another activity in your AndroidManifest.xml file which is LoginActivity.
<activity android:name=".LoginActivity"/>
Add this under OnBoardingActivity in your manifest like the following.
<activity android:name=".OnBoardingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity"/>
You need to LoginActivity extends with AppCompatActivity. And also declare in AndroidManifest.xml file.
public class LoginActivity extends AppCompatActivity {}
And add in your AndroidManifest.xml
<activity android:name=".LoginActivity"/>
From your code and your manifest file. It is clear that you didn't add LoginActivity in your AndroidManifest.xml file
You need to add LoginActivity in your AndroidManifest.xml like this below code.
<activity android:name=".LoginActivity"/>
Full source code of the following manifest will be looked like this below code.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="">
<application
android:name=".MyApp"
android:icon="#mipmap/ic_launcher">
<activity android:name=".OnBoardingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity" />
</application>
</manifest>
Related
I have a splash screen in my project it opens first with intent filter. After that it opens the main activity. But i created new activity that should be opened next to splash screen how to do that?
I have created three activities for example splash screen, main activity, login screen, Splash screen first opens next to that i need to open the login screen next only main activity.
xml code
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_main"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_main_round"
android:supportsRtl="true"
android:theme="#style/Theme.WeatherApp">
<activity
android:name=".SplashScreen"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".HomeActivity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden"
tools:ignore="LockedOrientationActivity" />
</application>
There are few ways to achieve this. This is one of my way.
First, at your AndroidManifest.xml, make sure you make your SplashActivity becomes your launcher. Then, at the onCreate method for your SplashActivity, do some delay, checking some stuff, is this user login or not. Last, go to next activity.
<activity
android:name="company.com.ui.SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
new Handler().postDelayed(
new Runnable() {
#Override
public void run() {
Intent intent = new Intent(SplashScreen.this, Login.class);
finish();
}
},
4000);
I am new to Android Studio and to the OS and have been designing an application, I tried to add a splash screen to my application after creating the splash screen and adding it to my manifest file but I keep getting this error:
Could not identify launch activity: Default Activity not found Error
while Launching activity
The tutorial I followed to get the splash screen provides no insight to correcting this error.
Below is my entire manifest file if someone could correct me I would be grateful.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gui.prog">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Display" ></activity>
<activity android:name=".Signup" ></activity>
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.category.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Just copy paste file,
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"/>
<activity android:name=".Display" ></activity>
<activity android:name=".Signup" ></activity>
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.category.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
It will work, as currently it is unable to know which activity is initial one.
What I like to do for a 'SplashActivity' is set my 'MainActivity' as a regular activity, and set my 'SplashActivity' as the default activity that will begin on launch.
My AndroidManifest.xml:
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" ></activity>
Then in my SplashActivity's 'onCreate' method:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread timerThread = new Thread(){
public void run(){
try{
sleep(2000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
}
}
};
timerThread.start();
}
you cant put two intent filters in the android manifest file if you want to launch app with spalsh screen activity you have to put the intent filter in the splash activity
I created a new class in my project called UserTypeSelection.java and wanted to set it as the main activity which launches when I run the app. I've changed the manifest file to contain an intent filter and also tried editing the configurations to set it as the default activity, however I keep receiving the error:
Error running app: The activity must be exported or contain an intent-filter
My manifest file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.XXXXX.computerscienceinduction">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".UserTypeSelection" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity android:name=".RegistrationActivity"></activity>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".ProfileActivity" />
</application>
</manifest>
How can I resolve this issue. Any help is appreciated, thank you.
You are closing your activity xml tag before you have specified the IntentFilter.
Change your declaration to this.
<activity android:name=".UserTypeSelection" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
UserTypeSelection must be activity and it must be using intent filters you have not closed activity after intent filter it is closed before.
Try this,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.XXXXX.computerscienceinduction">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".UserTypeSelection">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegistrationActivity"/>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".ProfileActivity" />
</application>
</manifest>
the purpose of this activity/program is to simply switch from this activity to another one using a button. From IzzynActivity to notes. Here is the android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="izzy.n"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="izzy.n.IzzynActivity"
android:label="#string/app_name" >
<activity
android:name="izzy.n.notes"
android:label="#string/notes"></activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And here is the IzzynActivity.java code:
package izzy.n;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class IzzynActivity extends Activity{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button wg = (Button) findViewById(R.id.button1);
wg.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(IzzynActivity.this, notes.class);
IzzynActivity.this.startActivity(myIntent);
}
});
}
}
An activity cannot contain another activity in the AndroidManifest.xml file. Here's the right code:
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="izzy.n.IzzynActivity"
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="izzy.n.notes"
android:label="#string/notes"></activity>
</application>
</manifest>
Note:
If you return anything with setResult() from a started activity you should start it using startActivityForResult.
For the warning message:
Just edit one piece of code and re-run your application. It will be reinstalled on the phone and you should not see the warning message again.
For one you have an activity tag inside another activity tag in your manifest which is clearly wrong.
Change your manifest to this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="izzy.n"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".IzzynActivity"
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=".notes"
android:label="#string/notes">
</activity>
</application>
</manifest>
<activity
android:name="izzy.n.IzzynActivity"
android:label="#string/app_name" >
<activity
android:name="izzy.n.notes"
android:label="#string/notes"></activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
you are declareing an activity inside another activity without closing first one: so replace this block with:
<activity
android:name="izzy.n.IzzynActivity"
android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="izzy.n.notes"
android:label="#string/notes"></activity>
<intent-filter>
</activity> closing tag for your first activity should come before starting tag for your second activity. You are nesting your activities, which is not permitted.
I'm trying to start an Activity (StartGame) from inside of a SurfaceView once I touch in a certain spot. This code is inside the OnTouchEvent
It won't accept what I have below, of course, but I don't know what to put in the Context space.
I've tried my package (com.Juggle2.Menu), but that doesn't work, because it can't resolve it to a variable, and "this" doesn't work because it's a class. I don't know what else to try.
startActivity(new Intent(com.Juggle2.Menu, StartGame.class));
This does not work because "com.Juggle2.Menu cannot be resolved to a variable"
My Manifest is as follows
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Juggle2"
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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".StartGame">
</activity>
<activity android:name = ".Help">
</activity>
<activity android:name = ".Options">
</activity>
<activity android:name = ".Credits">
</activity>
</application>
And my project goes com.Juggle2>Menu.java
Try startActivity(new Intent(com.Juggle2.Menu.this, StartGame.class));
Edit working:
Context context = com.Juggle2.Menu.this.getContext();
context.startActivity(new Intent(context, StartGame.class));