receiver

How to access Switch button that is declared in MainActivity(layout) in BroadcastReceivers

我的未来我决定 提交于 2020-01-22 03:40:10
问题 I have a task in which i have to change state of Switch button when airplane mode is ON/OFF. I have a main activity in which i declared Switch Button and i want to Change the state on/off of Switch from BroadcastReceiver Class Receiver public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { boolean isAirplaneModeOn = intent.getBooleanExtra("state", false); if(isAirplaneModeOn){ What Should i do ? } } } layout_main_activity <?xml

Receive midi input with javax.sound.midi

放肆的年华 提交于 2020-01-15 09:41:52
问题 I would like to have a program that could do something when it gets a midi input. For instance when I click button 1 on my controller it should print "You clicked btn 1" and when I click button 2 it should print "You clicked btn 2". I tried using the javax.sound.midi library but all the examples in forums or on youtube didn't work for. This worked the most for me. It printed all of the Midi Devices of my PC but it didn't receive anything. Can anybody help? package de.snke.dev; import javax

How to receive images via Bluetooth

允我心安 提交于 2020-01-07 08:36:10
问题 I want to receive images via Bluetooth and display that image in Image View.I know how to pass image from one activity to another activity but i don't no how to receive images using Bluetooth. 回答1: Android framework provides access to the Bluetooth functionality through the Android Bluetooth APIs. These APIs let applications wirelessly connect to other Bluetooth devices, enabling point-to-point and multipoint wireless features. Using the Bluetooth APIs, an Android application can perform the

getting battery level at android widget

若如初见. 提交于 2020-01-01 08:56:28
问题 I wrote a widget for Android and I'm trying to get the battery level. I've tried using Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); but I get the error: "IntentReceiver components are not allowed to register to receive intents" Why? the ACTION_BATTERY_CHANGED is a sticky intent and I don't register a receiver (null in the first parameter). Any workaround? Thanks. 回答1: hackbod gave the solution at the comments: " use

android:enable and services

∥☆過路亽.° 提交于 2019-12-29 17:51:10
问题 I m currently learning how create and use services on android. I looked on the android SDK for further help and i found the android:enable=[true | false] . in the SDK is said that: The and attributes must both be "true" (as they both are by default) for the service to be enabled. If either is "false", the service is disabled; it cannot be instantiated. So i would like to know what is the interest of/ why (in general) setting the application enables as "false". setting the service enable as

Run service on incoming SMS in android Oreo

天涯浪子 提交于 2019-12-29 07:44:09
问题 I'm developing an app which needs to run some code (Networking) whenever an SMS is received. In API 25 and lower it's fine, I register an implicit receiver in Manifest file and start my service in the specified class which extended BroadcastReceiver . In API 26 however you cannot register android.provider.Telephony.SMS_RECEIVED in a receiver since it won't work. From Android documentation: Note: If your app targets API level 26 or higher, you cannot use the manifest to declare a receiver for

Option<Receiver> Moved in Previous Loop Iteration

落花浮王杯 提交于 2019-12-25 02:59:11
问题 I'm spawning a thread that does some work. Sometimes I want this thread to die after the work is finished, other times I want it to wait for more work to do. To do this I pass in an Option<Receiver<T>> . If Option<Receiver<T>> is None the thread should die, else it should wait to receive more work. fn foo(rx: Option<Receiver<usize>>) { thread::spawn(move || { loop { do_some_work(); if let Some(r) = rx { match r.recv() { Ok(x) => {} Err(_) => panic!("Oh no!"), } } else { break; //Die } } }); }

QPSK transmission and reception in GNURadio

白昼怎懂夜的黑 提交于 2019-12-24 18:33:33
问题 I have implemented this: Constellation plot of receiver side is same as that of transmitter but it disappears for some moment and is not continuous, It flickers and keeps on moving around and for a very short moment show a garbage plot also. How to resolve that to get a correct continuous plot? 回答1: Never use a "Throttle" block in a hardware flow graph. What it does is just slow down the processing speed "about roughly" to the requested rate on average. That will sooner or later lead to your

Python IRC ChatBot hangs on socket.recv after seemingly random time even though socket.settimeout is 8

一笑奈何 提交于 2019-12-24 07:12:13
问题 Hey so I decided to create an IRC ChatBot whose sole purpose it is to read incoming messages from Twitch Chat and if a giveaway is recognized by a keyword it's supposed to enter the giveaway by sending !enter in Chat. I build the Bot upon this source: https://github.com/BadNidalee/ChatBot. I only changed things in the Run.py so thats the only Code I'm going to post. The unaltered ChatBot does work but it has no reconnect ability and regularly stops receiving data because the socket closes or

Why is my Receiver for charging status always returning false?

你离开我真会死。 提交于 2019-12-23 13:19:10
问题 I'm trying to detect when a user plugs (or unplugs) in their device to charge. In my receiver, where I determine whether it is plugged in or not, I always get a "false" reading on the status. Here is my code: (In the manifest): <receiver android:name=".PowerConnectionReceiver" > <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /> </intent-filter> </receiver> Here is the