The android app I had created is not crashing in the emulator nor the phone I am using but shows some exceptions like java.lang.NoSuchMethodError: in the logcat, but when I transfer the apk file to other devices then 80% of the users reported the app got crashed while just opening the app or opening an activity with on the app.
This is driving me crazy I tested this on different emulators and none of them got crashed.I just couldn't understand what the problem is please help.
MY AndroidMaifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androgeekzz.pokemongo_bestguidetipsandtricks">
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Basics" />
<activity android:name=".Tips" />
<activity android:name=".Tricks" />
<activity android:name=".Bas_What" />
<activity android:name=".Bas_Downld" />
<activity android:name=".Bas_Pikatchu" />
<activity android:name=".Bas_PokeCapture" />
<activity android:name=".Bas_LVI5" />
<activity android:name=".Bas_GainXP_LVL_Up" />
<activity android:name=".Bas_All_Iteams" />
<activity android:name=".Bas_All_Places" />
<activity android:name=".Advanced" />
<activity android:name=".Adv_gainXP" />
<activity android:name=".Adv_1candies" />
<activity android:name=".Adv_2Evolution" />
<activity android:name=".Adv_3PowerUp" />
<activity android:name=".Adv_4FightAGym" />
<activity android:name=".Adv_5DefendGym" />
<activity android:name=".Adv_6LvlGym" />
<activity android:name=".Adv_7Type" />
<activity android:name=".Adv_8Egg" />
<activity android:name=".Tips_0Good" />
<activity android:name=".Tips_1Eevee" />
<activity android:name=".Tips_2EarnXP" />
<activity android:name=".Tips_3Find" />
<activity android:name=".Tips_4Nest" />
<activity android:name=".Adv_Nests" />
<activity android:name=".Resources"></activity>
</application>
Main Activity:
package com.androgeekzz.pokemongo_bestguidetipsandtricks;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
public class MainActivity extends AppCompatActivity {
SharedPreferences prefs;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
prefs = getSharedPreferences("myPrefs", MODE_PRIVATE);
int times = prefs.getInt("ok_clicked", 0);
if (times == 0) {
new AlertDialog.Builder(MainActivity.this).setTitle("Hi there user").setMessage("This app version right now is just 1.0 the later versions will be released soon with even more content,Images and in app video tutorials etc..and this app is completely ADD free so please do consider rating it. ").setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
prefs = getSharedPreferences("myPrefs", MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt("ok_clicked", 1);
editor.apply();
}
}).show();
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
public void basicsOnclick(View view) {
Intent i = new Intent(this, Basics.class);
startActivity(i);
}
public void advanceOnclick(View view) {
Intent i = new Intent(this, Advanced.class);
startActivity(i);
}
public void tipsOnclick(View view) {
Intent i = new Intent(this, Tips.class);
startActivity(i);
}
public void tricksOnclick(View view) {
Intent i = new Intent(this, Tricks.class);
startActivity(i);
}
public void resourceLinksOnclick(View view) {
Intent i = new Intent(this, Resources.class);
startActivity(i);
}
public void aboutOnclick(View view) {
new AlertDialog.Builder(MainActivity.this).setTitle("About").setMessage("App Name :Pokemon GO-Guide\nVersion :1.0 \nCreator :Prudhvi").setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
LogCat (It had not crashed for this log cat)-
at com.android.systemui.statusbar.SignalClusterView.apply(SignalClusterView.java:468)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1986)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1679)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.onReceive(NetworkControllerImpl.java:643)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:895)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
08-07 23:23:38.730 824-824/?
E/Xposed: java.lang.NoSuchMethodError: com.mediatek.systemui.ext.DefaultStatusBarPlugin#getDataNetworkTypeIconGemini(com.mediatek.systemui.ext.NetworkType,int)#exact
at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:170)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:131)
at com.ceco.lollipop.gravitybox.ModStatusBar$24.afterHookedMethod(ModStatusBar.java:1072)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:689)
at com.mediatek.systemui.ext.PluginFactory.getStatusBarPlugin(<Xposed>)
at com.android.systemui.statusbar.SignalClusterView.apply(SignalClusterView.java:401)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1986)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1679)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.onReceive(NetworkControllerImpl.java:643)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:895)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
08-07 23:23:38.731 824-824/?
E/Xposed: java.lang.NoSuchMethodError: com.mediatek.systemui.ext.DefaultStatusBarPlugin#getDataNetworkTypeIconGemini(com.mediatek.systemui.ext.NetworkType,int)#exact
at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:170)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:131)
at com.ceco.lollipop.gravitybox.ModStatusBar$24.afterHookedMethod(ModStatusBar.java:1072)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:689)
at com.mediatek.systemui.ext.PluginFactory.getStatusBarPlugin(<Xposed>)
at com.android.systemui.statusbar.SignalClusterView.getNullIconIdGemini(SignalClusterView.java:557)
at com.android.systemui.statusbar.SignalClusterView.apply(SignalClusterView.java:468)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1986)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1679)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.onReceive(NetworkControllerImpl.java:643)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:895)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
Related
I want to automatically launch my app on TV startup. i.e. when the user power on the TV, TV will powerup and my app will start.
I have followed multiple links on internet and tried to implement it but no activity is shown on startup.
Followed
How to start/ launch application at boot time Android
As I was not getting any response on start, followed Android-Boot Completed is not working in Broadcastreceiver
I have extensively searched web and stackoverflow, it is strange that I cannot find a solution to make it work till now. Don't know what am I doing wrong...
here is my code...
MainActivity.java
public class MainActivity extends FragmentActivity {
public WebView mWebview;
private android.content.Context Context;
private ProgressDialog mProgressDialog;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
String url = "http://www.test.com";
if (!DetectConnection.checkInternetConnection(this)) {
Toast.makeText(getApplicationContext(), "No Internet Connection!", Toast.LENGTH_LONG).show();
finish(); //Calling this method to close this activity when internet is not available.
} else {
WebView webView = (WebView) findViewById(R.id.main_fragment);
webView.getSettings().setJavaScriptEnabled(true);
CookieManager.getInstance().setAcceptCookie(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
WebSettings webSettings = webView.getSettings();
webSettings.setDomStorageEnabled(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webSettings.setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(url);
}
}
StartAppOnBoot.java
public class StartAppOnBoot extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() == null) {
return;
}
//if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean startupAfterBoot = prefs.getBoolean("serenity_boot_startup", false);
if (startupAfterBoot) {
Intent i = new Intent(context, MainActivity.class);
//i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
Manifest.xml
<?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.test.tv2"
tools:ignore="MissingLeanbackLauncher">
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:icon="#drawable/ic_banner"
android:label="TV2"
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning"
android:banner="#mipmap/tv_banner_foreground">
<activity android:name="com.test.tv2.MainActivity"
android:screenOrientation="landscape"
android:theme="#style/Theme.Leanback"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.test.tv2.StartAppOnBoot"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>
I need to know how to make an application that I created in Android and made in Android Studio runs automatically when the device boots.
The only thing I have found is this guide https://codigofacilito.com/articulos/auto-ejecucion-de-una-aplicacion-al-inicio-de-un-depositivo-con-android but it does not run when the device starts.
ANDROID MANIFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.resolucion.pruebaauto">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:enabled="true"
android:name=".Auto"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
</manifest>
BROADCAST RECEIVER
package com.resolucion.pruebaauto;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class Auto extends BroadcastReceiver{
public void onReceive(Context context,Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
MAINACTIVITY
package com.resolucion.pruebaauto;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
I have problem with splash screen. It shows only for half a second and disappears a few seconds before activity HomeZastepowy appears. I made this splash screen based on this site https://android.jlelse.eu/right-way-to-create-splash-screen-on-android-e7f1709ba154. Where i made a mistake?
MainActivity code:
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import java.util.Objects;
public class MainActivity extends AppCompatActivity {
FirebaseAuth mAuth;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAuth = FirebaseAuth.getInstance();
if (mAuth.getCurrentUser() != null) {
String uid = mAuth.getUid();
final DocumentReference mDocRef = FirebaseFirestore.getInstance().collection("Data").document("userInfo").collection(Objects.requireNonNull(uid)).document(uid);
mDocRef.get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
#Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists()) {
String user = documentSnapshot.getString("user");
assert user != null;
if (user.equals("user")) {
Log.d("tag", String.valueOf(mAuth.getUid()));
Intent intent = new Intent(getApplicationContext(),
HomeUsrActivity.class);
startActivity(intent);
finish();
} else {
Log.d("tag", "Zastepowy");
Log.d("tag", String.valueOf(mAuth.getUid()));
startActivity(new Intent(MainActivity.this, HomeZastepowy.class));
finish();
}
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_SHORT).show();
}
});
finish();
}else {
Intent intent = new Intent(getApplicationContext(),
HomeActivity.class);
startActivity(intent);
finish();
}
}
}
AndroidManifest code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.zapp4">
<application
android:allowBackup="true"
android:fullBackupContent="#xml/backup_descriptor"
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=".HomeUsrActivity"></activity>
<activity android:name=".LoginActivity" />
<activity android:name=".punktyog" />
<activity android:name=".punktywz" />
<activity android:name=".HomeZastepowy" />
<activity android:name=".tradycje" />
<activity android:name=".wiedza" />
<activity android:name=".kontakt" />
<activity android:name=".zastepy" />
<activity android:name=".historia" />
<activity android:name=".onas" />
<activity android:name=".HomeActivity" />
<activity android:name=".MainActivity" android:theme="#style/SplashScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think the problem is that you forgot to remove this line from your code:
setContentView(R.layout.activity_main)
Because you setContentView, it overrides your theme background. So try to comment this line and give it a try.
i have a application that allows me to alter/add/delete from mysql database. The application opens up fine when i run it but when i try clicking on the 'ViewAllEmployee' button i keep getting a error saying it cannot find explicit activity class. I have looked online and tried all solutions that have worked for people with this problem before. I have added it into my AndroidManifest too but it still doesn't want to work. Can anyone help? Literally been trying to fix this for hours!
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.assignment.androidassignment"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:label="#string/app_name" >
<activity
android:name="com.example.assignment.androidassignment.MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name="com.example.assignment.androidassignment.ViewAllEmployee"
/>
</activity>
</application>
</manifest>
MainActivity.java -- Error showing when onClick for 'ViewAllEmployee' is clicked:
package com.example.assignment.androidassignment;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.util.HashMap;
public class MainActivity extends Activity implements View.OnClickListener{
//Defining views
private EditText editTextLatitude;
private EditText editTextLongitude;
private EditText editTextTimeInserted;
private Button buttonAdd;
private Button buttonView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initializing views
editTextLatitude = (EditText) findViewById(R.id.editTextLat);
editTextLongitude = (EditText) findViewById(R.id.editTextLon);
editTextTimeInserted = (EditText) findViewById(R.id.editTextTimeInserted);
buttonAdd = (Button) findViewById(R.id.buttonAdd);
buttonView = (Button) findViewById(R.id.buttonView);
//Setting listeners to button
buttonAdd.setOnClickListener(this);
buttonView.setOnClickListener(this);
}
//Adding an employee
private void addEmployee(){
final String lat = editTextLatitude.getText().toString().trim();
final String lon = editTextLongitude.getText().toString().trim();
final String timeInserted = editTextTimeInserted.getText().toString().trim();
class AddEmployee extends AsyncTask<Void,Void,String>{
ProgressDialog loading;
#Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(MainActivity.this,"Adding...","Wait...",false,false);
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
loading.dismiss();
Toast.makeText(MainActivity.this,s,Toast.LENGTH_LONG).show();
}
#Override
protected String doInBackground(Void... v) {
HashMap<String,String> params = new HashMap<>();
params.put(Config.KEY_LAT,lat);
params.put(Config.KEY_LON,lon);
params.put(Config.KEY_TIMEINSERTED,timeInserted);
RequestHandler rh = new RequestHandler();
String res = rh.sendPostRequest(Config.URL_ADD, params);
return res;
}
}
AddEmployee ae = new AddEmployee();
ae.execute();
}
#Override
public void onClick(View v) {
if(v == buttonAdd){
addEmployee();
}
if(v == buttonView){
startActivity(new Intent(this,com.example.assignment.androidassignment.ViewAllEmployee.class));
}
}
}
LogCat errors:
12-09 03:34:46.634 2489-2489/? E/AndroidRuntime: FATAL EXCEPTION: main
=Process: com.example.assignment.androidassignment, PID: 2489
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.assignment.androidassignment/com.example.assignment.androidassignment.ViewAllEmployee}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
at android.app.Activity.startActivityForResult(Activity.java:3424)
at android.app.Activity.startActivityForResult(Activity.java:3385)
at android.app.Activity.startActivity(Activity.java:3627)
at android.app.Activity.startActivity(Activity.java:3595)
at com.example.assignment.androidassignment.MainActivity.onClick(MainActivity.java:91)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
You are nesting <activity> tags in your Manifest. Take them apart:
<activity
android:name="com.example.assignment.androidassignment.MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.assignment.androidassignment.ViewAllEmployee"/>
from
if(v == buttonView){
startActivity(new Intent(this,com.example.assignment.androidassignment.ViewAllEmployee.class));
}
to
if(v == buttonView){
startActivity(new Intent(MainActivity.this,ViewAllEmployee.class));
}
from
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.assignment.androidassignment"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:label="#string/app_name" >
<activity
android:name="com.example.assignment.androidassignment.MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name="com.example.assignment.androidassignment.ViewAllEmployee"
/>
</activity>
</application>
</manifest>
to
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.assignment.androidassignment"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:label="#string/app_name" >
<activity
android:name="com.example.assignment.androidassignment.MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.assignment.androidassignment.ViewAllEmployee"
/>
</application>
</manifest>
please change the above and this is happening because of nesting of activity inside manifest
Brand new to android development and I wanted to test some new code that I was working on. So I launched the my app on the emulator and the splash screen loads fine.However after the 5 second timer finishes the app crashes.
This is my Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.PackageName.alarmclock"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<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.PackageName.AlarmClock.MENU" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.PackageName.AlarmClock.ASDF" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TextPlay"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.PackageName.AlarmClock.TextPlay" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Email"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.PackageName.AlarmClock.Email" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Camera"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.PackageName.AlarmClock.Camera" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is my splash.java
OnCreate is dashed out in eclipse and I don't know why and if that is the reason for the crashing
package com.PackageName.alarmclock;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity{
MediaPlayer ourSong;
#Override
#Deprecated
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
ourSong.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent openMainActivity = new Intent("com.PackageName.AlarmClock.MENU");
startActivity(openMainActivity);
}
}
};
timer.start();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}
And if you need it, here is the Menu.Java
package com.PackageName.alarmclock;
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 Menu extends ListActivity{
String classes[] = { "MainActivity", "TextPlay", "Splash", "Email", "Camera", "example5", "example6"};
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.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.PackageName.AlarmClock." + cheese);
Intent ourIntent = new Intent(Menu.this, ourClass);
startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
And here is the LogCat
07-16 00:48:16.120: E/AndroidRuntime(1985): FATAL EXCEPTION: Thread-84
07-16 00:48:16.120: E/AndroidRuntime(1985): Process: com.PackageName.alarmclock, PID: 1985
07-16 00:48:16.120: E/AndroidRuntime(1985): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.PackageName.AlarmClock.MENU }
07-16 00:48:16.120: E/AndroidRuntime(1985): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
07-16 00:48:16.120: E/AndroidRuntime(1985): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
07-16 00:48:16.120: E/AndroidRuntime(1985): at android.app.Activity.startActivityForResult(Activity.java:3424)
07-16 00:48:16.120: E/AndroidRuntime(1985): at android.app.Activity.startActivityForResult(Activity.java:3385)
07-16 00:48:16.120: E/AndroidRuntime(1985): at android.app.Activity.startActivity(Activity.java:3627)
07-16 00:48:16.120: E/AndroidRuntime(1985): at android.app.Activity.startActivity(Activity.java:3595)
07-16 00:48:16.120: E/AndroidRuntime(1985): at com.PackageName.alarmclock.Splash$1.run(Splash.java:28)
Any help is appreciated as I've spent pretty much the whole day on this app and It'd suck to lose it.
Add this to your manifest:
<activity
android:name=".Menu"
android:label="#string/app_name" >
</activity>
Call it in Intent as :
Intent openMainActivity = new Intent(Splash.this, Menu.class);
Right now what you have in your manifest is:
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
which, from the code that you have pasted, doesn't exist.
Leave alone, the ListActivity in java file has the name "Menu" and what you declared in manifest is "MENU"
Try this
Intent openMainActivity = new Intent(getApplicationContext(), Menu.class);
You have to use intents something like this
Intent i=new Intent(Firstactivity.this,SecondActivity.class);
startActivity(i);
Where first activity is your current activity and second activity is the one you want to move on to; but in your finally block you are doing something like
Intent openMainActivity = new Intent("com.PackageName.AlarmClock.MENU");//wrong
//you specified only one argument
startActivity(openMainActivity);
which is wrong
Change this line in Splash.java file
Intent openMainActivity = new Intent("com.PackageName.AlarmClock.MENU");
to
Intent openMainActivity = new Intent();
openMainActivity.setClass(this, Menu.class);
And
in Menu.java file change from
Class<?> ourClass = Class.forName("com.PackageName.AlarmClock." + cheese);
Intent ourIntent = new Intent(Menu.this, ourClass);
startActivity(ourIntent);
to
Intent ourIntent = new Intent();
ourIntent.setClass(this, AlarmClock.class);
startActivity(ourIntent);