Make an autoclicker to dial keystrings - java

I want to make an app which will dial keystrings for me in phone dialer.
On clicking button in an app the app goes in background and open phone app and by autoclicking it will dial keystring.

Even if you can auto click call button on different phone are positioned in different positions. If you want to make a call from your app you can just use Intent
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+8802177690));//change the number
startActivity(callIntent);
and add to your Manifest
<uses-permission android:name="android.permission.CALL_PHONE" />

Related

How to ask for the permission to become Default Video Player in Android?

I am developing a video player app and I want my app to Prompt for the permission to be the default Video Player to be the default handler of video play.
I know it has to be something like the default handler:
Intent setSmsAppIntent =
new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
setSmsAppIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
getPackageName());
startActivityForResult(setSmsAppIntent, your-result-code);`
source: Android Docs
But I don't know the Action I have to give to the Intent as action. Can someone please help me?
Thanks in advance.
It's not possible, developers can't call intent to change default Video player only users can do that on their device. Its only possible for SMS service.
However, for video player you can register app for video player in AndroidManifest.xml and call the function which opens settings to change default apps using the following code:
Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Android data turning on android data settings on button click

I have an app that does a check if data services is turned on and if it is not turned let display and alert dialog demanding the user to turn the app on clicking ok. This is my code that is supposed to show the settings of the android phone
final Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.Settings");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
The above code does not display the option to turn on the wifi of the user
Please why the wifi data not turned on, on clicking the button
To enable the option to allow the user to turn on data services such wifi and others.
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
Just call the generic Settings screen (ACTION_SETTINGS)
Reference link http://developer.android.com/reference/android/provider/Settings.html
That will do the trick

How to redirect User from Gallery TO my application in ANdroid?

When user taps gallery button I want user to redirect to my application's activity which will ask the user to enter password and then redirect user back to gallery ..
I want to know which permissions should i use and which broadcast should i accept .
Well If you want to lock the gallery you can do it in encrypt Decrypt way...
You can use MediaStore to access the images and then encrypt using your application and when user Again want to access that you can allow him to show by decrypting ...
Read the following link
Can I create password protected folder in Android?
You would need to replace the gallery application entirely to do what you're proposing.
When a user taps the Gallery icon, it doesn't fire a broadcast. It sends a directed intent with the action set to MAIN.
Anything that anyone tells you for how to do this is going to be wrong. You cannot do it.
The closest you could get is to use the MediaStore in your own app to access the same images that the gallery accesses.
Start a thread from your app which should periodically monitor foreground app name which in this case should be the Gallery (I cant remember the exact name But you can find it out using below logic).
Then if it is Gallery, open up your activity by blocking it.
If password success close activity & background will be the Gellery or otherwise redirect to Home.
For monitor foreground app
try {
ActivityManager activityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(1);
PackageManager pm = getApplicationContext().getPackageManager();
output1 = pm.getApplicationLabel(pm.getApplicationInfo(runningTasks.get(0).baseActivity.getPackageName(),PackageManager.GET_META_DATA)).toString();
String className = runningTasks.get(0).topActivity.getClassName();
if( className.contains("Gallery")) {
//better to create this object globally outside the thread.
Intent intentSettingLock = new Intent();
intentSettingLock.setClass(oContext,SettingsLockNew.class);
intentSettingLock.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
oContext.startActivity(intentSettingLock);
}
}
catch(Exception e) {
}
To redirect to home on invalid password
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
this.finish();
You can not perform this as you described because pressing the gallery app icon from the launcher the system fires an intent with action=MAIN and category=LAUNCHER for the specific application package.
Since you cannot name your application package as the gallery package name you cant filter this intent.

Bring app in background to front

I am making an app that gives an alarm when you are close to a gps position. now when a user presses the home button this app get send to the back. When the users enters the region to trigger the alarm, the alarm triggers but the app isn't send to the foreground.
How can i do this?
I tried this
Intent intent = new Intent(context, TrainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(intent);
in the function of the alarm, but this does nothing? (Trainactivity is the class that runs on the background and the class that needs to be on the foreground)
The REORDER_TO_FRONT flag only controls the stacking order on the activity history. That is not what you want. Is this what you are looking for ? - Bring application to front after user clicks on home button

how to manage hardware of android cell phone

I am using Android emulator and development platform.
I have created a new application and wonder how can I close or open Android cell phone camera?
If you are talking about opening it from your app you should use the camera Intent for that.
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
startActivityForResult(intent, 1);
EDIT:
1 - is for the front-facing camera
When you create the AVD for your emulator, there are options for enabling front and back camera. If you have enabled this option for your emulator, you will be able to access the camera just like you would on a regular phone (using the camera app, or via the system).
You probably didn't enable the camera option on your emulator image if you are not seeing it.
I am going to assume you have enabled a camera on your emulator, and want to access it's functions yourself, instead of opening an existing camera application. You'll need to use functions in Android to actually access this hardware, and you'll also need to give the app permission to use it.
private void startCamera(){
//First check if a camera is available
if(getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)){
Log.d("CameraApp", "It has a camera");
Camera cam = Camera.open(); //Start using the camera. From here on out you should be able to access it's functions.
cam.unlock();
cam.startPreview();
} else {
Log.d("CameraApp", "It does not have a camera");
Toast.makeText(this, "No camera available",
Toast.LENGTH_SHORT).show();
}
}
Be sure to close it when you're done.
private void stopCamera(){
cam.stopPreview();
cam.release();
}
Add this to your AndroidManifest.xml to give your app permission:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
Each function (zoom, autofocus, etc.) needs it's own permission to be added.
Also see this for more information: http://developer.android.com/reference/android/hardware/Camera.html

Categories