Reputation: 169
here my code
View view = getLocalActivityManager().startActivity("saved",
new Intent(v.getContext(),Saved_jobs.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
replaceView(view);
I am using this code to open new activity inside of tabHost and open activity perfectly and all control click event working fine
But when i click on imageview then application crashing
Imageview click event code
imageView.setBackgroundResource(R.drawable.starapplied);
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
// TODO Auto-generated method stub
//Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_SHORT).show();
AlertDialog.Builder builder = new AlertDialog.Builder(RecentlyViewd.this);
builder.setTitle("Are you sure you want to delete this job?");
// builder.setMessage("whould You like to save job");
builder.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
db.DeleteLocation(v.getTag().toString());
Toast.makeText(getApplicationContext(), "Job Deleted !",10).show();
startActivity(new Intent(RecentlyViewd.this,RecentlyViewd.class));
finish();
}
});
builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
dialog.cancel();
}
});
builder.show();
}
});
LogCat:
01-03 15:54:11.205: E/ActivityThread(1092): Failed to find provider info for com.android.inputmethod.latin.dictionarypack
01-03 15:54:11.205: E/BinaryDictionaryGetter(1092): Could not find a dictionary pack
01-03 15:54:17.685: E/AndroidRuntime(2771): FATAL EXCEPTION: main
01-03 15:54:17.685: E/AndroidRuntime(2771): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@b67b6b98 is not valid; is your activity running?
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.view.ViewRootImpl.setView(ViewRootImpl.java:585)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:326)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.view.Window$LocalWindowManager.addView(Window.java:547)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.app.Dialog.show(Dialog.java:277)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
01-03 15:54:17.685: E/AndroidRuntime(2771): at com.jobDiagnosis.RecentlyViewd$SavedAdapter$1.onClick(RecentlyViewd.java:196)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.view.View.performClick(View.java:4084)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.view.View$PerformClick.run(View.java:16966)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.os.Handler.handleCallback(Handler.java:615)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.os.Handler.dispatchMessage(Handler.java:92)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.os.Looper.loop(Looper.java:137)
01-03 15:54:17.685: E/AndroidRuntime(2771): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-03 15:54:17.685: E/AndroidRuntime(2771): at java.lang.reflect.Method.invokeNative(Native Method)
01-03 15:54:17.685: E/AndroidRuntime(2771): at java.lang.reflect.Method.invoke(Method.java:511)
01-03 15:54:17.685: E/AndroidRuntime(2771): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-03 15:54:17.685: E/AndroidRuntime(2771): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-03 15:54:17.685: E/AndroidRuntime(2771): at dalvik.system.NativeStart.main(Native Method)
01-03 15:54:19.475: E/Trace(2806): error opening trace file: No such file or directory (2)
01-03 15:54:19.815: E/ActivityThread(1092): Failed to find provider info for com.android.inputmethod.latin.dictionarypack
01-03 15:54:19.815: E/BinaryDictionaryGetter(1092): Could not find a dictionary pack
01-03 15:54:19.925: E/ActivityThread(1092): Failed to find provider info for com.android.inputmethod.latin.dictionarypack
01-03 15:54:19.925: E/BinaryDictionaryGetter(1092): Could not find a dictionary pack
01-03 15:54:20.265: E/BufferQueue(786): [] drainQueueLocked: BufferQueue has been abandoned!
Please Help Me
It's very important task for me
Thanks in Adavance
Upvotes: 0
Views: 205
Reputation: 18933
If you are using TabGroupActivity then change to this one:
from
AlertDialog.Builder builder = new AlertDialog.Builder(RecentlyViewd.this);
to
AlertDialog.Builder builder = new AlertDialog.Builder(getParent());
Upvotes: 1
Reputation: 366
instead of
AlertDialog.Builder builder = new AlertDialog.Builder(RecentlyViewd.this);
use this.
AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
Upvotes: 0