Ok so I am really new to Android, and to get going with things, I paid a developer to build me a simple app, and now I'm trying to wade through it to make sense of it.
The problem I am trying to solve is the initial launch screen the app goes to. I got this to change by going into the Android manifest file and changing this value:
<activity android:label="@string/app_name" android:name="Home">
to this value:
<activity android:label="@string/app_name" android:name="Languages">
And when I deploy the app to my device, it loads the Languages class just fine! The problem is that when I leave the app and then try and go back in, it doesn't even try to launch the app, it just goes back to the home screen.
There isn't anything that tells me what is going on, and attaching the debugger for after the app is initially closed won't work either.
Does anybody have any ideas as to what might be going on?
Here is the code from the Android Manifest file:`
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name="Language">
<intent-filter>
<action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="About"></activity>
<activity android:theme="@android:style/Theme.Light" android:name="Language"></activity>
<activity android:name="Volume" android:theme="@android:style/Theme.Light"></activity>
<activity android:name="Book" android:theme="@android:style/Theme.Light"></activity>
<activity android:name="Chapter" android:theme="@android:style/Theme.Light"></activity>
<activity android:name="Verse" android:theme="@android:style/Theme.NoTitleBar"></activity>
<activity android:name="Settings"></activity>
</application>
`
Then here is the code for the Home class which originally launched first:`package com.elan.reader;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.elan.reader.util.DatabaseHelper;
import com.elan.reader.util.DatabaseHelper_Spa;
public class Home extends Activity implements View.OnClickListener{
/** Called when the activity is first created. */
Button aboutBtn,readBtn;
Home me;
DatabaseHelper myDatabaseAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
me=this;
aboutBtn = (Button) findViewById(R.id.about);
aboutBtn.setFocusable(true);
aboutBtn.setOnClickListener(this);
readBtn = (Button) findViewById(R.id.read);
readBtn.setFocusable(true);
readBtn.setOnClickListener(this);
myDatabaseAdapter = DatabaseHelper.getInstance(me);
if(!myDatabaseAdapter.databaseReady()){
try{
myDatabaseAdapter.copyDatabase2();
DatabaseHelper_Spa myDatabaseAdapter_spa = DatabaseHelper_Spa.getInstance(me);
myDatabaseAdapter_spa.copyDatabaseSpanish2();
}catch(Exception e){
e.printStackTrace();
}
myDatabaseAdapter.databaseReady();
}else{
//myDatabaseAdapter.close();
if(myDatabaseAdapter.getSaveVerse()[0]!=null||!myDatabaseAdapter.getSaveVerse()[0].equals("")){
String data[]=myDatabaseAdapter.getSaveVerse();
Intent intent=new Intent(Home.this, Verse.class);
intent.putExtra("language",data[0]);
intent.putExtra("volume_id",data[1]);
intent.putExtra("chapter",data[2]);
intent.putExtra("book",data[3]);
intent.putExtra("book_id",data[4]);
intent.putExtra("multiple_languages",false);
startActivity(intent);
}
}
}
@Override
public void onClick (View view){
if(view==aboutBtn){
startActivity(new Intent(Home.this, About.class));
}else if(view==readBtn){
ProgressBar seek = (ProgressBar) findViewById(R.id.seek);
seek.setVisibility(View.VISIBLE);
TextView msg = (TextView) findViewById(R.id.loading);
msg.setVisibility(View.VISIBLE);
new Thread(){
public void run(){
Looper.prepare();
if(myDatabaseAdapter.getSaveVerse()[0]==null||myDatabaseAdapter.getSaveVerse()[0].equals("")){
startActivity(new Intent(Home.this, Language.class));
}else{
String data[]=myDatabaseAdapter.getSaveVerse();
Intent intent=new Intent(Home.this, Verse.class);
intent.putExtra("language",data[0]);
intent.putExtra("volume_id",data[1]);
intent.putExtra("chapter",data[2]);
intent.putExtra("book",data[3]);
intent.putExtra("book_id",data[4]);
intent.putExtra("multiple_languages",false);
startActivity(intent);
}
Looper.loop();
}
}.start();
}
}
}`
And then here is the code for the new class I need to launch first:`package com.elan.reader;
import java.util.ArrayList;
import com.elan.reader.util.DatabaseHelper;
import com.elan.reader.util.DatabaseHelper_Spa;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Chronometer;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class Language extends ListActivity {
/** Called when the activity is first created. */
private ArrayList<SettingsObject> m_orders = null;
private AboutAdapter m_adapter;
private Runnable viewOrders;
String[] listData={"English","French"};
//Bitmap[] listImage;
private Runnable returnRes = new Runnable() {
@Override
public void run() {
if(m_orders != null && m_orders.size() > 0){
m_adapter.notifyDataSetChanged();
for(int i=0;i<m_orders.size();i++)
m_adapter.add(m_orders.get(i));
}
m_adapter.notifyDataSetChanged();
}
};
ImageView backBtn;
static boolean running=false;
static long startTime=0;
static Chronometer timer ;
static long hit_id=-1;
static int stopped=0;
Context me;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.title_list_menu);
me=this;
DatabaseHelper myDatabaseAdapter;
myDatabaseAdapter = DatabaseHelper.getInstance(me);
if(!myDatabaseAdapter.databaseReady()){
try{
myDatabaseAdapter.copyDatabase2();
DatabaseHelper_Spa myDatabaseAdapter_spa = DatabaseHelper_Spa.getInstance(me);
myDatabaseAdapter_spa.copyDatabaseSpanish2();
}catch(Exception e){
e.printStackTrace();
}
myDatabaseAdapter.databaseReady();
}else{
//myDatabaseAdapter.close();
if(myDatabaseAdapter.getSaveVerse()[0]!=null||!myDatabaseAdapter.getSaveVerse()[0].equals("")){
String data[]=myDatabaseAdapter.getSaveVerse();
Intent intent=new Intent(Language.this, Verse.class);
intent.putExtra("language",data[0]);
intent.putExtra("volume_id",data[1]);
intent.putExtra("chapter",data[2]);
intent.putExtra("book",data[3]);
intent.putExtra("book_id",data[4]);
intent.putExtra("multiple_languages",false);
startActivity(intent);
}
}
// listImage=new Bitmap[]{BitmapFactory.decodeResource(getResources(), R.drawable.sharing),BitmapFactory.decodeResource(getResources(), R.drawable.contact_us),BitmapFactory.decodeResource(getResources(), R.drawable.about)};
m_orders = new ArrayList<SettingsObject>();
this.m_adapter = new AboutAdapter(this, R.layout.language_row, m_orders);
setListAdapter(this.m_adapter);
viewOrders = new Runnable(){
@Override
public void run() {
getOrders();
}
};
Thread thread = new Thread(null, viewOrders, "MagentoBackground");
thread.start();
}
@Override
protected void onListItemClick(ListView li, View v, int position, long id) {
super.onListItemClick(li, v, position, id);
Intent intent=new Intent(Language.this, Volume.class);
intent.putExtra("language",""+position);
startActivity(intent);
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
System.out.println("onRestart");
//loadImages();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
System.out.println(" onResume");
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
System.out.println("onStart");
}
private class AboutAdapter extends ArrayAdapter<SettingsObject> {
private ArrayList<SettingsObject> items;
public AboutAdapter(Context context, int textViewResourceId, ArrayList<SettingsObject> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.language_row, null);
}
final SettingsObject o = items.get(position);
if (o != null) {
TextView title = (TextView) v.findViewById(R.id.title);
if (title != null) {
title.setText(o.getName());
}
}
return v;
}
}
private void getOrders(){
try{
m_orders = new ArrayList<SettingsObject>();
for(int i=0;i<listData.length;i++){
SettingsObject temp = new SettingsObject(listData[i]);
m_orders.add(temp);
}
} catch (Exception e) {
e.printStackTrace();
}
runOnUiThread(returnRes);
}
class SettingsObject {
private String name;
public String getName() {
return name;
}
public SettingsObject(String name) {
this.name = name;
}
}
} `
Not sure if this is the cause of your problem but in your AndroidManifest.xml you have 2 activity entries for Language. You should remove the second entry.
<activity android:theme="@android:style/Theme.Light" android:name="Language"></activity>