activity

How to move Bluetooth activity into a Service

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The application gives the users 2 connection options, USB and Bluetooth. USB works fine. I have obtained sample codes for Bluetooth connection, however they are designed to work as activity. I tried to do it in a Service but failed. BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); startService(new Intent(this, MyService.class)); <service android:enabled="true" android:name=".MyService" /> enter code here I need to establish Bluetooth communication with a device that is already paired and its MAC address is known. So

IllegalStateException: Can not perform this action after onSaveInstanceState with ViewPager

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting user reports from my app in the market, delivering the following exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1109) at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:399) at android.app.Activity.onBackPressed(Activity.java:2066) at android.app.Activity.onKeyUp(Activity.java:2044) at android.view.KeyEvent.dispatch(KeyEvent.java:2529) at android.app.Activity.dispatchKeyEvent

Cancel notification on remove application from multitask panel

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I manage an ONGOING notification from my application (not from a service). When I kill application from task manager with "End" button, notification disappear . When I remove application from multitask pannel, application is killed but notification remains . My questions are: How to catch this event to clear notification? What happens when application is removed from multitask pannel? Application is destroyed but process staying alive? Is it normal? As an update: All my activities extends MyActivity class (which extends Activity) with

Android app out of memory issues - tried everything and still at a loss

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I spent 4 full days trying everything I can to figure out the memory leak in an app I'm developing, but things stopped making sense a long time ago. The app I'm developing is of social nature, so think profile Activities (P) and list Activities with data - for example badges (B). You can hop from profile to a badge list to other profiles, to other lists, etc. So imagine a flow like this P1 -> B1 -> P2 -> B2 -> P3 -> B3, etc. For consistency, I'm loading profiles and badges of the same user, so each P page is the same and so is each B page.

Android Activity as a dialog

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an Activity named whereActity which has child dialogs as well. Now, I want to display this activity as a dialog for another activity. How can I do that? 回答1: To start activity as dialog I defined it like this in AndroidManifest.xml : <activity android:theme="@android:style/Theme.Dialog" /> Use this property inside your activity tag to avoid that your Dialog appears in the recently used apps list android:excludeFromRecents="true" If you want to stop your dialog / activity from being destroyed when the user clicks outside of the dialog:

NullPointerException accessing views in onCreate()

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is a canonical question for a problem frequently posted on StackOverflow. I'm following a tutorial. I've created a new activity using a wizard. I get NullPointerException when attempting to call a method on View s obtained with findViewById() in my activity onCreate() . Activity onCreate() : @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); View something = findViewById(R.id.something); something.setOnClickListener(new View.OnClickListener() { ... }

How to launch activity only once when app is opened for first time?

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have an activity that i only want to run when the application is ran for the first time. And never again. It is a facebook login activity. I only want to launch it once when the app is initially opened for the first time. How do i go about doing this? 回答1: What I've generally done is add a check for a specific shared preference in the Main Activity : if that shared preference is missing then launch the single-run Activity, otherwise continue with the main activity . When you launch the single run Activity create the shared

Use a persistent notification to allow the user to return to running Android app

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am developing an app with numerous Activities. I would like to create a persistent notification that (more or less) says, "AppName - Return to AppName" that will be present whenever my background services are running. Creating and disposing of the notification was no problem. Now, the user could be on any of several screens/Activities, leave the application, then want to re-enter the app via the notification. The problem is , the notification must have an intent, which launches a predetermined Activity . I want the notification to re-enter

NullPointerException On Android.os.Bundle

匿名 (未验证) 提交于 2019-12-03 02:01:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some problem with my code, when I need to transfer some data from one Activity to another one. First Activity ( ViewCashflow ) and I want transfer some data from ViewCashflow to second Activity ( NewTransaction ). Here its working well with no error, the data transferred successfully. But, I don't know what's going on when I run the second Activity directly (not from first Activity like before when I transfer the data) I got null pointer exception on the method that I use to receive the data from first Activity . I have tried to

android eclipse button OnClick event

匿名 (未验证) 提交于 2019-12-03 02:01:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have 2 files: main_activity.xml and home.xml. I made a button in main_activity.xml Here is the code snippet: And then, I have my home.xml. I want the button to open up home.xml. How can i do this? I don't know any java and I am new to android development. Here is my home.xml below: And below is my AndroidManifest.xml: And that's all I have. Please, if you reply, tell me where to add the code such as the directory or between code snippets. 回答1: For managing click activity in android ,you can do as below Implement OnClickListener on