Android Splash Screen to FragmentActivity - java

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>

Related

Problem when I try to open another window from a button the app closes completely "Android Studio"

i'm a student and i'm working on a mobile app.
The probleme is that my app was working, but now when i click on the button to open another window it closes.
Here is my code:
`
public class MainActivity extends AppCompatActivity {
Button b_inscrire_etudiant;
Button b_inscrire_enseignant;
Button b_inscrire_admin;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b_inscrire_etudiant = findViewById(R.id.b_inscrire_etudiant);
b_inscrire_enseignant = findViewById(R.id.b_inscrire_enseignat);
b_inscrire_admin = findViewById(R.id.b_inscrire_admin);
b_inscrire_etudiant.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this , InscriptionEtudiant.class);
startActivity(i);
}
});
b_inscrire_enseignant.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this , InscriptionEnseignant.class);
startActivity(i);
}
});
b_inscrire_admin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this , InscriptionAdmin.class);
startActivity(i);
}
});
}
}
`
I worked as usual "using Intent" besides it worked well until now.
Here is my Manifest file:
<?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="com.example.myusto">
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.MyUsto"
tools:targetApi="31">
<activity
android:name=".InscriptionEnseignant"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".InscriptionEtudiant"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".InscriptionAdmin"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".Connexion"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
ps: I solved the problem, by the way two were missing
Thank you for the answers.
It's true, it was missing a part of the code which was not written in the manifest file

Integrating Snap-kit in android

I am trying to add snap-kit in my application and I have integrated everything as their documentation. App successfully launched Snapchat app but it's not login it shows an error Something is wrong Here is my complete code and other implementation. This is the official documentation that I have followed https://kit.snapchat.com/docs/login-kit-android
MainActivity
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding binding;
private static final String TAG = "MAIN_ACTIVITY";
String query = "{me{bitmoji{avatar},displayName}}";
String variables = null;
boolean isUserLoggedIn;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
isUserLoggedIn = SnapLogin.isUserLoggedIn(this);
if (isUserLoggedIn)
binding.btnLogin.setText("Logout");
else
binding.btnLogin.setText("Logout");
binding.btnLogin.setOnClickListener(v -> {
SnapLogin.getAuthTokenManager(this).startTokenGrant();
binding.progress.setVisibility(View.VISIBLE);
});
SnapLogin.getLoginStateController(this).addOnLoginStateChangedListener(mLoginStateChangedListener);
SnapLogin.fetchUserData(this, query, null, new FetchUserDataCallback() {
#Override
public void onSuccess(#Nullable UserDataResponse userDataResponse) {
if (userDataResponse == null || userDataResponse.getData() == null) {
return;
}
MeData meData = userDataResponse.getData().getMe();
if (meData == null) {
return;
}
binding.txtName.setText(userDataResponse.getData().getMe().getDisplayName());
if (meData.getBitmojiData() != null) {
Glide.with(MainActivity.this)
.load(meData.getBitmojiData().getAvatar())
.into(binding.imgProfile);
}
}
#Override
public void onFailure(boolean isNetworkError, int statusCode) {
}
});
}
final LoginStateController.OnLoginStateChangedListener mLoginStateChangedListener =
new LoginStateController.OnLoginStateChangedListener() {
#Override
public void onLoginSucceeded() {
// Here you could update UI to show login success
binding.progress.setVisibility(View.VISIBLE);
Log.d(TAG, "onLoginSucceeded: ");
binding.btnLogin.setText("Logout");
}
#Override
public void onLoginFailed() {
// Here you could update UI to show login failure
binding.progress.setVisibility(View.VISIBLE);
Log.d(TAG, "onLoginFailed: ");
}
#Override
public void onLogout() {
// Here you could update UI to reflect logged out state
binding.progress.setVisibility(View.VISIBLE);
Log.d(TAG, "onLogout: ");
}
};
}
Manifests
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iotait.snapchatandroid">
<uses-permission android:name="android.permission.INTERNET" />
<queries>
<package android:name="com.snapchat.android" />
</queries>
<application
android:name=".application.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.SnapchatAndroidDemo">
<meta-data
android:name="com.snapchat.kit.sdk.clientId"
android:value="**********************" />
<meta-data
android:name="com.snapchat.kit.sdk.redirectUrl"
android:value="*********************" />
<meta-data
android:name="com.snapchat.kit.sdk.scopes"
android:resource="#array/snap_connect_scopes" />
<activity android:name=".ui.sign.SigninActivity"
android:screenOrientation="nosensor"/>
<activity android:name=".ui.intro.IntroActivity"
android:screenOrientation="nosensor"/>
<activity android:name=".ui.login.LoginActivity"
android:screenOrientation="nosensor"/>
<activity
android:name=".ui.splash.SplashActivity"
android:screenOrientation="nosensor"
android:theme="#style/Theme.splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.MainActivity"
android:screenOrientation="nosensor" />
<activity
android:name="com.snapchat.kit.sdk.SnapKitActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="lmk"
android:path="/oauth2"
android:scheme="lmk" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
Dependencies
implementation([
'com.snapchat.kit.sdk:login:1.1.4',
'com.snapchat.kit.sdk:core:1.1.4'
])
You need to add these line in the application tag
<meta-data android:name="com.snapchat.kit.sdk.clientId" android:value="1aab4ace-3f06-487d-bc85************"/>
<meta-data android:name="com.snapchat.kit.sdk.redirectUrl" android:value="https:********"/>
<meta-data android:name="com.snapchat.kit.sdk.scopes" android:resource="#array/snap_connect_scopes"/>
Use like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iotait.snapchatandroid">
<uses-permission android:name="android.permission.INTERNET" />
<queries>
<package android:name="com.snapchat.android" />
</queries>
<application
android:name=".application.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.SnapchatAndroidDemo">
<meta-data android:name="com.snapchat.kit.sdk.clientId" android:value="1aab4ace-3f06-487d-bc85************"/>
<meta-data android:name="com.snapchat.kit.sdk.redirectUrl" android:value="https:********"/>
<meta-data android:name="com.snapchat.kit.sdk.scopes" android:resource="#array/snap_connect_scopes"/>
<activity android:name=".intro.IntroActivity"/>
<activity android:name=".login.LoginActivity"/>
<activity
android:name=".splash.SplashActivity"
android:theme="#style/Theme.splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity
android:name="com.snapchat.kit.sdk.SnapKitActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="lmk" android:host="lmk" android:path="/oauth2"/>
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>

How to change or set new activity launcher app? (in Java)

I have a payment activity and splash activity that it shows app of contents after user will buy it. payment activity is default Launcher in Manifest.xml that I want to set launcher Activity to splash activity and payment activity disabled after payment.
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exa.iu2">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".PaymentActivity" android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="return" android:host=“zrp”/>
</intent-filter>
</activity>
<activity-alias
android:name=".PaymentActivity"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:enabled="false" android:targetActivity=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar"/>
</application>
</manifest>
in Payment Activity and "If payment is success"
public void onCallbackResultVerificationPayment(boolean isPaymentSuccess, String refID, PaymentRequest paymentRequest) {
if(isPaymentSuccess){
Toast.makeText(PaymentActivity.this, “Payment Success” + refID, Toast.LENGTH_SHORT).show();
ComponentName cm = new ComponentName("com.exa.iu2", "com.exa.iu2"+".SplashActivity");
ComponentName cm2 = new ComponentName("com.exa.iu2", "com.exa.iu2"+".PaymentActivity");
PackageManager pm = getApplication().getPackageManager();
pm.setComponentEnabledSetting(cm, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,PackageManager.DONT_KILL_APP);
pm.setComponentEnabledSetting(cm2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,0);
}else {
Toast.makeText(PaymentActivity.this, “Don’t success”, Toast.LENGTH_SHORT).show();
}
}
});
Thx
I suggest you create a Hub or Startup activity in which decide what to display. The new activity has to be set as Main -> Launcher activity, obviously.
In AndroidManifest do this
<activity android:name=".SplashActivity"
android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Inside SplashActivity
public class SplashActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// Check condition to open appropriate activity
// like
// if(paymentDone) start some activity
// else start another activity
finish()
}
}

Launcher activity not found

So I am redoing my app so that there will be an animation on the start screen of the app. The only problem is it seems you cannot start an app with a view class. At least I'm not really sure if you can. Here is my code. With this code i get a launcher activity not found in the console?
public class SplashLaunch extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.splashlaunch);
final Main d = new Main(this);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
setContentView(d);
}
}, 5000);
}
}
Here is the manifest file. I have a feeling that I'm going to need to change this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Tripps.thesimplegame"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".SplashLaunch"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SPLASHLAUNCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".YouFailed"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.YOUFAILED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Likely somewhere in your launcher activity you have an onCreate method:
public class YourActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.foobar);
}
}
Just change the setContentView to your custom view:
public class YourActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
MyCustomView view = new MyCustomView(this);
setContentView(view);
}
}
The Activity that you want to start when the app first starts MUST have the following Intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Apk android ActivityNotFoundException

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>

Categories