ActivityNotFoundException
Hi and thank you for reading my question. I am a new so bear with me. I have am app that I have divided into two activities
- Find the server/Login and
- display a TabActivity with three web pages that are generated on the server.
I have an ImageView in both layouts that acts as a splash screen while the WebViews are loading. It is tagged "visible" while the WebView and TabViews are marked "gone".
The signIn WebView is the main entry point and loads in the background. If all is good a page with the word "symbol" is loaded. My WebViewClient is listening with the onPageFinished(WV,Str)
method.
Problem:
I can not seem to successfully call the TabActivity from the signIn Activity(ActivityNotFoundException)
.
I have both activities listed in the Manifest.
I have done this in two of my last apps so I'm going crazy here.
I'm at the point where I may have changed too much code and have a blatant mistake. Please forgive me.
I have tried to startActivity(Intent)
directly from the WVC and by calling another method 开发者_JS百科startTabView()
so there is extra code that is confusing.
I have tried declaring the Intent first, adding the component and calling startActivity(context, intent)
.
I have written the one line startActivity(new Intent("string class name"))
.
I feel like my intent may be null.
have a look:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
phoneID = "" + tm.getDeviceId() ;
onStart();
}
public void setLoginVisible(){
ImageView splash = (ImageView) findViewById(R.id.splash);
splash.setVisibility(View.GONE);
signIn.setVisibility(View.VISIBLE);
signIn.requestFocus();
Toast.makeText(getApplicationContext(), phoneID, Toast.LENGTH_LONG);
}
public void startTabView(){
try{
startActivity( new Intent(this,WizForex.class));
}catch (ActivityNotFoundException anf){
Toast.makeText(getApplicationContext(), anf.toString(), Toast.LENGTH_LONG).show();
}catch (Exception e){
Toast.makeText(this, e.toString(), Toast.LENGTH_LONG);
}
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
wvc= new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
if (url.contains("NCdisclaimer")) setLoginVisible();
else if (url.contains("symbol")){
startTabView();
}
}
};
signIn = (WebView) findViewById(R.id.signIn);
signIn.getSettings().setJavaScriptEnabled(true);
signIn.setWebViewClient(wvc);
signIn.loadUrl("http://www.thewizard........"+ phoneID);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!-- Splash View -->
<ImageView
android:id="@+id/splash"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/splash"
android:visibility="visible"/>
<!-- signIn View -->
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/signIn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Eric.Sheasby.wiz"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="WizFinder"
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=".WizForex"
android:label="@string/app_name">
</activity>
<activity android:name=".Tester"
android:label="@string/tester">
`
Sorry this is so long. What have I done?
The problem might be that you are calling startTabView()
from within an action handler (an other thread, not the ui!).
You should give a try instantiating a Handler (mHandler):
private static final int LOAD_TABVIEW = 10; //or any other number
private final Handler handler = new Handler()
{
public void handleMessage(Message msg)
{
switch (msg.what)
{
case LOAD_TABVIEW:
startTabView();
break;
default:
break;
}
};
};
and in your onPageFinished(WebView view, String url)
method you should change a line
startTabView();
to
//send message to the handler:
mHandler.sendEmptyMessage(LOAD_TABVIEW);
This way your mHandler's handleMessage
gets called, and it should start the TabView.
精彩评论