activity

Android 1.6: “android.view.WindowManager$BadTokenException: Unable to add window ― token null is not for an application”

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to open a dialog window, but every time I try to open it it throws this exception: Uncaught handler: thread main exiting due to uncaught exception android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application at android.view.ViewRoot.setView(ViewRoot.java:460) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) at android.app.Dialog.show(Dialog.java:238) at android.app.Activity.showDialog(Activity

Error while Launching activity

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I recently downloaded Android Studio 2.0 and create a new startup app and did not add anything code by myself. After running the app, android studio installs the APK on emulator successfully but does not launch the app instead it gives the following error: $ adb shell am start -n "com.example.muhammad.firstapp/com.example.muhammad.firstapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Unexpected error while executing: am start -n "com.example.muhammad.firstapp/com.example.muhammad.firstapp.MainActivity" -a

Setting new pages linked by an Activity

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: In the application I am writing, I have a main class which extends the ListActivity - it contains a list of elements. I want these elements to link to a different page (an xml one, or perhaps a View object). However, I realised one cannot use the method setContentView(int) on a ListActivity object. What's to be done? Thanks! 回答1: Looks like you are trying to launch a new activity. You have to override the onListItemClick method of ListActivity . Here is the code. // ListView l points to list view whose item user clicked // View v

How to implement OnFragmentInteractionListener

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a wizard generated app with navigation drawer in android studio 0.8.2 I have created a fragment and added it with newInstance() and I get this error: com.domain.myapp E/AndroidRuntime: FATAL EXCEPTION: main java.lang.ClassCastException: com.domain.myapp.MainActivity@422fb8f0 must implement OnFragmentInteractionListener I can't find anywhere how to implement this OnFragmentInteractionListener ?? It cannot be found even in android sdk documentation! MainActivity.java import android.app.Activity; import android.app.ActionBar; import

How to disable virtual home button in any activity?

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to disable 3 virtual buttons in any activity in my app. I disabled back button and multitask button somehow but I cannot dsable home button. I tried onAttachedToWindow() style answers on stackoverflow but they didn't work for me. I don't want to disable home button for entire app, I just want to disable it for a single activity window. Thanks for your helps! 回答1: NOTE : I highly encourage you not to do this in your app, if you want to deploy it. This is only to show how we can do it. Since Android 4 there is no effective method to

Inner PreferenceScreen not opens with PreferenceFragmentCompat

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My inner PreferenceScreen of PreferenceFragmentCompat is not showing, or seems to ignore tapping events. I created MyPreferenceFragment that extends PreferenceFragmentCompat public class MyPreferenceFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.preferences); } } then I changed my theme at styles.xml like */ /*--> */ /*--> */ /*--> */ /*--> */ And finally create my preferences.xml file like At the build.gradle I have added

Activity did not call finish? (API 23)

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am getting the following error and i have no clue as to why its happening. Error: 08 - 23 17 : 07 : 46.533 22454 - 22454 / com . a . b . c E / AndroidRuntime : FATAL EXCEPTION : main Process : com . a . b . c , PID : 22454 java . lang . RuntimeException : Unable to resume activity { com . a . b . c / com . a . b . c . MainActivity }: java . lang . IllegalStateException : Activity { com . a . b . c / com . a . b . c . MainActivity } did not call finish () prior to onResume () completing at android . app . ActivityThread .

Android M request permission non activity

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My widget makes calls to secure permissions outside of an Activity scope. Is it possible to request permissions for Android M outside of an Activity ? 回答1: If you want to request the permission from outside the activity you can create different class and extend the class from Activity. Use constructer to get and set Context for the class. public class Permissions extends Activity { private static final int MY_PERMISSIONS_WRITE_EXTERNAL_STORAGE = 1; private Context context; public Permissions(Context context) { this.context = context; }

Dagger2 Custom Scopes : How do custom-scopes (@ActivityScope) actually work?

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am reading the source code for Dagger2 Component Scopes Test on GitHub, and I've seen a "custom scope" defined for activities called @ActivityScope , but I've seen it in other projects including the 4-module CleanArchitecture that has its @PerActivity scope. But literally, the code for the @ActivityScope annotation is the following: import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import javax.inject.Scope; /** * Created by joesteele on 2/15/15. */ @Scope @Retention(RetentionPolicy.RUNTIME) public

How to disable grid item when activity is loaded

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have few grid items. Depending on the flag, I want to disable some grid items For example: Grid items are Order,CallLost,Payment. If boolean status = true, then I want to disable CallLost . Others should be enabled. If boolean status = false, then I want to disable Order , Payment & CallLost & I have done grid items using: @Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . retailer_main ); Bundle bundle = this . getIntent (). getExtras ();