问题
I assume this is the proper forum , not android.stackechange since it is software related.
I am a novice Java developer and need to create a custom Android telephony application with the following functionality
- launches automatically when device starts , boots
- launches in kiosk mode, no notifications, or access to other applications!
- has a single 'call' button which places a phone call to a hardwired phone number.
- has the ability to communicate 1 way simple data to external device(think arduino) via bluetooth. i.e. when call received signal to arduino to flash lights, etc
- optional display for either hardcoded message or number received.
Should I make use of a single Activity class?
What other classes should I create or make use of?
In order to properly test both incoming and outgoing calls do I need to first deploy to an actual device with an initialized(with phone number) SIM?
Are there any Android projects on Github or elsewhere that have parts of this functionality I might study and learn from?
Any other architecture tips or suggestions?
回答1:
Yes you can make single activity class. But as you want to add few functions so its better to create few activity classes. As its easy to check and manage smaller activity classes as compare to only one large activity class. And the number of classes depend upon functions. Its good if you create one class for one function.
1.For automatically launching it when device starts you can use following code-
public class YourReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent intent = new Intent(context, YourActivity.class);
context.startActivity(intent);
}
}
And add following code to your manifest file-
<receiver
android-permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:name="YourReceiver" >
<intent-filter >
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
2.For launching it in kiosk mode-
Is it possible to create an android app to make the phone run in sort of a kiosk mode?
3.For making phone calls-
How To Make A Simple Phone Call Application
How to make a phone call from your application
4.For bluetooth option-
Android Bluetooth sample app
回答2:
As I can see you are trying to unite several existing apps in one )
launches automatically when device starts , boots
launches in kiosk mode, no notifications, or access to other applications!
this two you can borrow from parental control apps like Kids Space launcher
1) I do not know examples on github but fisrt of all you make your application main launcher of device after this it will launches automatically when device starts , boots
2)
for in kiosk mode
try to google how to kill onother application (probably it will be your service that running all time and checks the system for unwanted applications have been launched and trying to kill them)
3)
has a single 'call' button which places a phone call to a hardwired phone number.
Yes just do it your launcher application as single Activity with one functionality - Dailer. There a lot of dailer example in internet. For example this one https://github.com/mirontoli/android-dialer;
...
In order to properly test both incoming and outgoing calls do I need to first deploy to an actual device with an initialized(with phone number) SIM?
Yes the better way for test is real devices.
来源:https://stackoverflow.com/questions/20600377/custom-android-telephony-application