android-service

Android call method in Service from Activity

瘦欲@ 提交于 2019-12-12 18:16:45
问题 I want to call a method in a Service object from an Activity object, however I have found it is not possible to call the method from the MainActivity normally. I hope my code explains what I mean better: Service: public class Timer extends Service { public Vibrator v; public MainActivity ma; public CountDownTimer mycounter; public static final String MY_SERVICE = "de.example.timer.MY_SERVICE"; public IBinder onBind(Intent arg0) { return null; } public void onCreate() { super.onCreate(); ma =

Notification Listener Service not started when running in debug mode

拟墨画扇 提交于 2019-12-12 17:45:27
问题 I am building an app using the NotificationListenerService. But always when I run the app in debug mode the Service is not started. I reduced my code to the following: My Acticity: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val intent = Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS") startActivity(intent) } override fun onResume() { super.onResume()

Android - Stop a Service from a different class

走远了吗. 提交于 2019-12-12 16:54:30
问题 In the application i'm making I want to start an intent in one activity Intent toonService = new Intent(Login.this, ToonService.class); toonService.putExtra("toonName", result.getName()); Login.this.startService(toonService); Will the following code close the intent i just opened? If not how can i get it to? Intent toonService = new Intent(MainActivity.this,ToonService.class); MainActivity.this.stopService(toonService); the second piece of code would be called at a time completly unrelated to

java.lang.SecurityException: without permission android.permission.BIND_INPUT_METHOD only for <=2.2

本秂侑毒 提交于 2019-12-12 15:47:19
问题 I have this very unpeculiar exception.The thing is have i have this app that has a button to start InputMethodService that starts like this public class MyGroovyIme extends InputMethodService { and this is how it looks in manifest. <service android:name=".MyGroovyIme" android:enabled="true" android:exported="true" android:permission="android.permission.BIND_INPUT_METHOD" > <intent-filter> <action android:name="android.view.InputMethod" /> <!-- <category android:name="android.intent.category

Android AWS S3 SDK TransferUtility Not Working in Service

时光毁灭记忆、已成空白 提交于 2019-12-12 12:28:08
问题 I am trying to use the AWS Android SDK for S3 in a started service. I am a little new to both the SDK and Services. I am pretty confident that the Transfer Utility is also running a service. Handler (android.os.Handler) {11629d87} sending message to a Handler on a dead thread java.lang.IllegalStateException: Handler (android.os.Handler) {11629d87} sending message to a Handler on a dead thread at android.os.MessageQueue.enqueueMessage(MessageQueue.java:325) at android.os.Handler.enqueueMessage

Prevent Live Wallpaper from changing screen orientation

為{幸葍}努か 提交于 2019-12-12 12:05:42
问题 I'm working on a Live Wallpaper and I would like to keep it always in portrait mode. I know it's possible for an Activity to declare the orientation in the Manifest, but I can't find a way to do the same with a live wallpaper service. Is it possible somehow to tell the Wallpaper Engine to swap the x and y axis in the rendering process or something similar, because I have no idea anymore. 回答1: Use the following method to check for orientation changes public void onSurfaceChanged(SurfaceHolder

Android Sensor Shake in the background

风流意气都作罢 提交于 2019-12-12 10:18:37
问题 I'm trying to follow a tutorial about sensor. It works fine with an activity. However, I want this to work in the background when the phone is locked. What's the best way to do that? Here's the link to the tutorial http://jasonmcreynolds.com/?p=388 ShakeDetector class public class ShakeDetector implements SensorEventListener { /* * The gForce that is necessary to register as shake. * Must be greater than 1G (one earth gravity unit). * You can install "G-Force", by Blake La Pierre * from the

Background services causing crash

那年仲夏 提交于 2019-12-12 09:55:13
问题 My issue might be blatent misunderstanding of services and my use of them, or a poss conflict with other apps. When I start a specific activity, I start two background services - location tracking to give distance travelled, and elapsed timer, both of which are passed to the activity with a BroadcastReceiver . I initiate each service with a Long through the Intent object from my primary Activity : if (!Utils.isServiceRunning(this, TrackService.class)) { Intent i = new Intent(this,

FirebaseApp with name [DEFAULT] doesn't exist getting error

本秂侑毒 提交于 2019-12-12 09:55:02
问题 Hi I am trying to get data on background service of Android. But I am getting this error. Here is my code: public class FirebaseBackgroundService extends Service { FirebaseDatabase database = FirebaseDatabase.getInstance(); private ValueEventListener handler; DatabaseReference myRef = database.getReference("chats"); @Nullable @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { super.onCreate(); handler = new ValueEventListener() { @Override

IntentService onHandleIntent() still running after onDestroy() fired

筅森魡賤 提交于 2019-12-12 09:48:01
问题 In my preference screen, I want to start a service to download files from the internet when one of the preference is being clicked. If the service is already running (downloading files), then the service should be stopped (cancel download). public class Setting extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); downloadPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean