activity

Dependencies from two components in one activity

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm playing with Dagger-2 to figure how to integrate it in our existing application and I'm facing something which I can't understand or I'm doing wrong. My situation : 3 API without any annotated constructor ( each one in its own file ) public class DbApi { public void doSomething ( String username , String password ) { } } public class RestApi { public void doSomething ( String username , String password ) { } } public class SocketApi { public void doSomething ( String username , String password ) { } } 3 Modules ( each one in

Activity class does not exist

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Aaaargh! I don't know what's going on, but suddenly I can't launch my app. I'm using IntelliJ and I keep getting this error. I thought maybe there was a typo somewhere in the manifest, but there doesn't seem to be. Heres' the error: Launching application: com.foo.app/com.foo.app.main. DEVICE SHELL COMMAND: am start -n "com.foo.app/com.foo.app.main" Starting: Intent { cmp=com.foo.app/.main} Error type 3 Error: Activity class {com.foo.app/com.foo.app.main} does not exist. And here's my Manifest: And the strange thing is that ADB shows me that

Reload activity in Android

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Is it a good practice to reload an Activity in Android ? What would be the best way to do it? this.finish and then this.startActivity with the activity Intent ? 回答1: You can Simply use finish (); startActivity ( getIntent ()); to refresh an Activity from within itself. 回答2: This is what I do to relad the activity after changing returning from a preference change. @Override protected void onResume () { super . onResume (); this . onCreate ( null ); } This essentially causes the activity to redraw itself. Updated: A better way to do

How do I detect if the user has left my app?

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 选择语言 中文(简体) 日语 英语 中文(繁体) 由 翻译 强力驱动 问题: I am developing an Android app and I want to detect when the user exits my app either by clicking the Back button or the Home button. Also, an event like onInit() would be useful in my scenario, as I just want to have the action start at first. onDestroy() is not called until other apps need more memory. 回答1: If your activity is the last in the stack then detecting a back button with onKeyDown would solve 1/2 of this The home key is a little trickier, there is no absolute method but you could do something

Android Context Memory Leak ListView due to AudioManager

匿名 (未验证) 提交于 2019-12-03 01:32:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a ListView and I would expect it to be cleared from memory when the activity finishes. However, it appears that it is leaking. When I check the Memory Dump, and get the pathToGC for the ListView I get the following, Class Name | Shallow Heap | Retained Heap android . widget . ExpandableListView @ 0x4063e560 | 768 | 39 , 904 |- list , mList com . hitpost . TeamChooser @ 0x405f92e8 | 176 | 1 , 648 | '- mOuterContext android.app.ContextImpl @ 0x40657368 | 160 | 304 | ' - mContext android . media . AudioManager @ 0x40662600 | 40

Launch custom android application from android browser

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Can anybody please guide me regarding how to launch my android application from the android browser? 回答1: Use an with a element. For example, to handle all links to twitter.com, you'd put this inside your in your AndroidManifest.xml : Then, when the user clicks on a link to twitter in the browser, they will be asked what application to use in order to complete the action: the browser or your application. Of course, if you want to provide tight integration between your website and your app, you can define your own scheme: Then, in your web

再说Activity的四种启动模式

纵然是瞬间 提交于 2019-12-03 01:30:16
Android启动模式分为四种,分别为:standard、singleTop、singleTask、singleInstance stander 标准启动模式: 这是Activity默认的启动模式,也是逻辑最简单的一种,只要Activity使用这种模式进行启动,系统会不管三七二十一,直接create一个Activity实例出来,然后加入到Task顶。 2. singleTop: 这中启动模式和standard的最大区别,就是它在启动时会检查Task顶部是否已经存在该Activity实例,if 存在 则重用已经存在的实例,else 重新创建一个activity实例并加入task顶部。 3.singleTask 这种启动模式相对于上面两个,就比较复杂。如果activity以这种模式启动,会执行下面的流程: a)系统会先为这个Activity加上Flag_new_task 的标签 b)获取该activity的 taskAffinity属性(该属性默认为应用程序的包名) c)检查系统中是否已经存在taskAffinity属性值所对应的Task: !)如果存在该Task:则先检查该Task中是否有目标Activity的实例,if存在,则清空该实例以上所有的Activity实例,将该Activity实例放在Task顶部。如果不存在,则重新创建一个该Activity的实例,并且加入到该Task中

Fullscreen Activity in Android?

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I make an activity full screen? I mean without the notification bar. Any ideas? 回答1: You can do it programatically: public class ActivityName extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // remove title requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); } } Or you can do it via your AndroidManifest.xml file: Edit: If you are using

Activity class does not exist (Error type 3)

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a device nexus5x with android O and i develop an app in my laptop and also in another computer. But when i want to start the app in another computer after i have started it in my laptop i always get error described below. Error while executing: am start -n "com.safetylink.android.safetylinkheartbeatapp/com.application.aware.safetylink.auth.SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.safetylink

How do I prevent the status bar and navigation bar from animating during an activity scene animation transition?

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Firstly, my status bar background is set to dark brown, and my navigation bar background is default black. I'm using the Material light theme. I'm starting a new activity using ActivityOptions.makeSceneTransitionAnimation with default transitions, and I notice that both the status and navigation bars briefly fade to white and then back to the correct colors. According to the documentation : To get the full effect of a transition, you must enable window content transitions on both the calling and called activities. Otherwise, the calling