我正在开发一个具有定位功能的应用程序。
当用户点击“定位我们”按钮时,用户将重定向到我想在谷歌地图上显示的特定位置。
这很好,我的应用程序重定向到谷歌地图应用程序,它打开我要显示的位置,但当我点击地图上的后退按钮时,它显示我的欢迎页面,有时它显示错误“不幸的地图已停止”。< / p>
我尝试了一切,但无法找到问题所在。任何人都可以帮助我。
这是我的Welcome.java活动:
package mainApplication;
import java.io.File;
import readFile.*;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Locale;
import logs.TraceLog;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.StrictMode;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;
import forbes.mPassbook.R;
public class Welcome extends Activity
{
ImageButton LoginHere,RegisterNow,Locate_us;
String uri ="https://www.google.co.in/maps/place/Bank+Of+Bahrain+And+Kuwait+BBK/@19.0822508,72.8812041,11z/data=!4m5!1m2!2m1!1sbank+of+bahrain+in+mumbai!3m1!1s0x3be7d1e96fffffff:0x5e96526f98c8e98";
String file_Path;
TraceLog tc =new TraceLog();
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
ActionBar bar=getActionBar();
bar.hide();
file_Path=Environment.getExternalStorageDirectory()+ "/Android/data/forbes.mPassbook/";
if( Build.VERSION.SDK_INT >= 9)
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
File conf=new File(file_Path + "config.properties");
if(!conf.exists())
{
copyFiles();
}
ReadConfig rc = new ReadConfig();
/****************GIF code implementation***********************/
/*ImageView img = (ImageView)findViewById(R.id.imageView2);
img.setBackgroundResource(R.drawable.gifanim);
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start();*/
LoginHere = (ImageButton)findViewById(R.id.image_user_login);
RegisterNow = (ImageButton)findViewById(R.id.image_register);
Locate_us =(ImageButton)findViewById(R.id.image_locateus);
RegisterNow.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
Intent i = new Intent(Welcome.this, Registration.class);
// // Closing all the Activities
// i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//
// // Add new Flag to start new Activity
// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
}
});
LoginHere.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
File file_cust_id=new File(file_Path + "customer.properties");
if(file_cust_id.exists())
{
Intent i = new Intent(Welcome.this, Login.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
}
else
{
Toast.makeText(getApplicationContext(),"Please Register First",Toast.LENGTH_LONG).show();
}
}
});
//Locate us button
Locate_us.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
try
{
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://www.google.co.in/maps/place/Bank+Of+Bahrain+And+Kuwait+BBK,+Ground+Floor,+225,+Jolly+Maker+Chambers,/@18.925573,72.824222,17z/data=!3m1!4b1!4m2!3m1!1s0x3be7d1e96fffffff:0x5e96526f98c8e98?hl=en"));
startActivity(intent);
// Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
// intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(intent);
// // finish();
}
catch(Exception ex)
{
Toast.makeText(getApplicationContext(),"Error In Google Maps",Toast.LENGTH_LONG).show();
}
}
});
}
//Copy Property Files from Asset Folder to SD card on startup
public void copyFiles()
{
try
{
File dataDirectory = new File(file_Path);
// have the object build the directory structure, if needed.
if(!dataDirectory.exists())
dataDirectory.mkdirs();
AssetManager am = getAssets();
String[] list = am.list("");
for (String s:list)
{
if (s.startsWith("config"))
{
InputStream inStream = am.open(s);
int size = inStream.available();
byte[] buffer = new byte[size];
inStream.read(buffer);
inStream.close();
FileOutputStream fos = new FileOutputStream(file_Path + s);
fos.write(buffer);
fos.close();
}
}
}
catch (Exception ex)
{
tc.WriteToTransactionLog("Exception: Welcome.java copyFiles():- "+ex.toString());
ex.printStackTrace();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ( keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
{
onBackPressed();
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onBackPressed()
{
try
{
//Success Register dialog box
Exit e = new Exit(Welcome.this);
e.show();
e.setCanceledOnTouchOutside(false);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void onDestroy()
{
super.onDestroy();
finish();
}
// public void onRestart()
// {
// super.onRestart();
// startActivity(new Intent(this, Welcome.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
// }
}
我的Welcome.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="forbes.welcome.Hdfc_welcome"
android:background="@drawable/bbk_base_screen">
- <ImageButton
android:id="@+id/image_user_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/image_register"
android:src="@drawable/user_login" />
<ImageButton
android:id="@+id/image_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/register" />
<ImageButton
android:id="@+id/image_locateus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/image_register"
android:layout_alignParentRight="true"
android:src="@drawable/locate_us_icon" />
<!-- <TextView
android:id="@+id/text_hdfc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/text_welcome"
android:layout_below="@+id/text_welcome"
android:layout_marginLeft="20dp"
android:textColor="#d4ccb9"
android:textSize="24sp"
android:textStyle="bold|italic"
android:text="M-Passbook" /> -->
<!-- <EditText
android:id="@+id/editText_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#d4ccb9"
android:drawableLeft="@drawable/user_icon"
android:layout_centerHorizontal="true"
android:layout_below="@+id/text_hdfc"
android:ems="10"
android:maxLength="15"
android:layout_marginTop="20dp"
android:hint="@string/user_name" >
</EditText>
<EditText
android:id="@+id/editText_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#d4ccb9"
android:drawableLeft="@drawable/key_icon"
android:ems="10"
android:maxLength="15"
android:hint="@string/password"
android:layout_centerHorizontal="true"
android:layout_below="@+id/editText_user"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:inputType="textPassword" />
<ImageButton
android:id="@+id/button_login"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignTop="@+id/editText_user"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/editText_password"
android:src="@drawable/unlock_icon" /> -->
<TextView
android:id="@+id/text_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/image_user_login"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp"
android:text="Welcome To mPassbook"
android:textColor="#d4ccb9"
android:textSize="24sp"
android:textStyle="italic" />
</RelativeLayout>
我的LogCat告诉我这个:
12-05 09:29:41.432: D/GraphicBuffer(11527): create handle(0x5e919910) (w:544, h:960, f:1)
12-05 09:29:41.436: D/GraphicBuffer(11527): close handle(0x5e919910) (w:544 h:960 f:1)
12-05 09:29:41.441: D/GraphicBuffer(11527): create handle(0x5e919910) (w:544, h:960, f:1)
12-05 09:29:41.494: D/OpenGLRenderer(11527): Flushing caches (mode 0)
12-05 09:29:50.212: V/InputMethodManager(11527): onWindowFocus: null softInputMode=32 first=true flags=#1810100
12-05 09:29:50.213: V/InputMethodManager(11527): START INPUT: com.android.internal.policy.impl.PhoneWindow$DecorView{41168cf0 V.E..... R......D 0,0-540,960} ic=null tba=android.view.inputmethod.EditorInfo@415c3e08 controlFlags=#104
12-05 09:29:50.215: V/InputMethodManager(11527): Starting input: Bind result=InputBindResult{com.android.internal.view.IInputMethodSession$Stub$Proxy@415c4698 com.android.inputmethod.latin/.LatinIME #7009}
12-05 09:29:50.239: D/GraphicBuffer(11527): create handle(0x5e0fe628) (w:544, h:960, f:1)
12-05 09:29:50.251: I/SurfaceTextureClient(11527): [STC::queueBuffer] (this:0x5c9eaeb0) fps:0.11, dur:8780.78, max:8780.78, min:8780.78
12-05 09:29:50.251: I/SurfaceTextureClient(11527): [STC::queueBuffer] this:0x5c9eaeb0, api:1, last queue time elapsed:8780.78