I am trying to use this 3rd Party Signature Capture Android Application with my PhoneGap Application. I have no idea how to "Call the right Activity" from my PhoneGap App. My Application is written in html and javascript.
Please help!
I have installed the application on my Droid X and it Captures my Signature with my finger. Its super smooth and quick.
http://www.binarysolutions.biz/
Here are the instructions from their website. They are not very detailed.
String key = ""; // set the key, any string you find suitable
String fileName = ""; // set the file name (global write permissions)
Intent intent = new Intent("biz.binarysolutions.signature.CAPTURE");
intent.putExtra(key, fileName);
intent.setComponent(
new ComponentName(
"biz.binarysolutions.signature",
"biz.binarysolutions.signature.Capture"
)
);
startActivityForResult(intent, CAPTURE_REQUEST_CODE);
Receiving the result
#Override
protected void onActivityResult
(
int requestCode,
int resultCode,
Intent data
) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAPTURE_REQUEST_CODE &&
resultCode == RESULT_OK) {
String fileName = ""; // the same file name as above
Bitmap bitmap = BitmapFactory.decodeFile(fileName);
// do with bitmap whatever you like
}
}
The integration of the signature application is doable via an Android Intent to invoke the signature app. Looks like you have the instructions for what you need to do on the Java (native) side to integrate with the signature application, but you are at a loss to do so inside a PhoneGap Android app.
Take a look at WebIntent. It is a PhoneGap Android plug-in - this is an extension to the PhoneGap API and is composed of a small JavaScript interface which your PhoneGap app uses, and a native (Java) component that the JS interface talks to. The WebIntent blog post linked above actually does a pretty good job of explaining a PhoneGap plug-in, too.
What you'll have to do on top of integrating the WebIntent plug-in is interfacing the WebIntent with the Signature app - so the intents getting passed around on the native side contain the proper parameters.
Starting from version 2.5 Signature Capture library can be started from the web browser just by clicking on a specific link. It can also 'upload' captured image to given url. Check out the instructions here:
http://www.binarysolutions.biz/2010/12/signature-capture-for-android.html#usage_web
Hope that could help.
Related
I am using Intent(Intent.ActionOpenDocument) and OnActivityResult() fine in my Android mobile app. (Targeting Android 10, API 29). The user selects an audio file and the app plays the file fine. Ths user is able to select a file from anywhere on their device.
I would like to display the name of the file that is playing in the UI. How do I grab the filename?
In OnActivityResult, this: ReturnedIntent.Data.Path, returns this:
/document/content://com.microsoft.skydrive.content.metadata/Drive/RID/phil%40mydomain.com/Item/RID/DC9388F99D04BA56%21369828/Property/?RefreshOption=AutoRefresh&RefreshTimeOut=15000&CostAttributionKey=11-21-1
which has nothing resembling the file name in it. I have found older stack posts on this, but they don't work for me. I have a feeling that the issue is with Android security and/or permissions that I need to give the app.
How do I grab the file name so I can display it in the UI?
Thanks #CommonsWare, you pointed me in the right direction. With the help of intellisense I noticed that the .Data property of the returned Intent was a Uri. So this is what (C# Xamarin) ended up working.
public override void OnActivityResult(int requestCode, int resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (resultCode == -1 && requestCode == 42)
{
Intent ReturnedIntent = data;
// the code is in a Fragment here so we use Activity for the Context
DocumentFile df = DocumentFile.fromSingleUri(Activity, ReturnedIntent.Data);
string FileName = df.Name; // that contains the filename
I never would have got this on my own. I love that Android Java and Xamarin C# are so close. Thanks again #CommonsWare.
I am developing on a Android 4.0.3 device. How do I open a file browser for my app? Is there one built in the to Android SDK? Do I have to write my own?
I don't want my app to depend on a the user installing a separate app for file browsing.
To get a file from a file browser, use this:
Intent fileintent = new Intent(Intent.ACTION_GET_CONTENT);
fileintent.setType("gagt/sdf");
try {
startActivityForResult(fileintent, PICKFILE_RESULT_CODE);
} catch (ActivityNotFoundException e) {
Log.e("tag", "No activity can handle picking a file. Showing alternatives.");
}
I'm not quite sure what the gagt/sdf is for... it seems to work in my app for any file.
Then add this method:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Fix no activity available
if (data == null)
return;
switch (requestCode) {
case PICKFILE_RESULT_CODE:
if (resultCode == RESULT_OK) {
String FilePath = data.getData().getPath();
//FilePath is your file as a string
}
}
If the user doesn't have a file manager app installed or preinstalled by their OEM you're going to have to implement your own. You might as well give them a choice.
I hope this one will help you for file picking:
public void performFileSearch() {
// ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file
// browser.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
// Filter to only show results that can be "opened", such as a
// file (as opposed to a list of contacts or timezones)
intent.addCategory(Intent.CATEGORY_OPENABLE);
// Filter to show only images, using the image MIME data type.
// If one wanted to search for ogg vorbis files, the type would be "audio/ogg".
// To search for all documents available via installed storage providers,
// it would be "*/*".
intent.setType("image/*");
startActivityForResult(intent, READ_REQUEST_CODE);
}
The code is from this documentation:
https://developer.android.com/guide/topics/providers/document-provider.html
Refer to it for more information.
If someone would still need it for newer versions, it got updated with developing Storage Access Framework by Google for SDK >= 4.4. Check this Google site for further details:
https://developer.android.com/guide/topics/providers/document-provider.html
There is no single file-management app that is installed across all devices.
You probably want your app to be also working on devices with Android 3.x or lower.
The best choice you have though is writing your own file-manager. It isn't as much effort as it might sound, there is a lot of code on this already out there on the web.
I need my app to read text via Camera. I know there's the Tesseract library which does this, but I'd really prefer if there was an app that can handle Intents to read text via Camera, like Xzing does for reading QR codes.
Is there such an app?
There isn't currently an app on Google Play that does this.
I've thought about making one, but the possible use cases for such an app vary much more than for, say, scanning a QR code. There are different possible scenarios:
License plate recognition
Recognition for LCD 7-segment displays
Korean OCR
OCR for stylized text
OCR with shadows or uneven illumination
The different scenarios present a challenge for how to handle the image. A request to such an app via Intent would probably need to specify at least the type of thresholding to use for pre-processing the image along with the language/traineddata file to use.
I've just created an app that takes a photo using the Camera, crop the photo, and return the recognized text as result.
In your app, you may use the following code:
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo("sunbulmh.ocr", PackageManager.GET_ACTIVITIES);
Intent LaunchIntent = pm.getLaunchIntentForPackage("sunbulmh.ocr");
LaunchIntent.setFlags(0);
startActivityForResult(LaunchIntent,5);
} catch (NameNotFoundException e) {
Uri URLURI = Uri.parse("http://play.google.com/store/apps/details?id=sunbulmh.ocr");
Intent intent = new Intent(Intent.ACTION_VIEW,URLURI);
startActivity(intent);
}
Then, get the result in onActivityResult():
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if(requestCode == 5){
String ocr_txt = data.getStringExtra(Intent.EXTRA_TEXT);
// ocr_txt contains the recognized text.
}
}
}
I'm making an Android app which stores some downloaded pdf files inside the device's SD card.
Everything works fine, but now I want to add a function to just pop up the default android file/folder browser showing the directory where my app stores all the PDF (with subdirectories in it) so that the user sees where his documents are stored and can easily browse them.
I've been throught many other SO questions and forum posts, but it seems this can only be done for music/images/contacts/etc. basically those file types which have a 'dedicated browsing system' but not with general file browsing.
I'm actually using this code:
File file = new File("/sdcard/MySorgenia/Documenti/");
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
Uri data = Uri.fromFile(file);
String type = "*/*";
intent.setDataAndType(data, type);
startActivity(intent);
But this will show me a "Choose the application to complete your action" dialog with many applications such as "Music" "Gallery" etc, but no general purpose one.
Thanks!
Because In android there is no any native application which you can use as a File Explorer and responds to Intent type "*/*"
Implement your own File-Explorer Code for this purpose..
Look at these two Links..
openintents
Android-File-Explore
public void loadfile()
{
private static final int gallery=12;
private static final String type="*/*";
Intent i=new Intent(Intent.ACTION_GET_CONTENT);
i.setType(type);
startActivityForResult(Intent.createChooser(i,"select file"), gallery);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == gallery && resultCode == RESULT_OK && data != null) {
Uri uploadfileuri = data.getData();
File file = new File(uploadfileuri.getPath());
}
}
Since Android 4.4 KitKat (API level 19), there is an Android built-in file picker: your app invokes the ACTION_OPEN_DOCUMENT and/or ACTION_CREATE_DOCUMENT intent and receives the files returned by document providers. More info about that can be found here:
Open files using storage access framework | Android Developers
Depending on where you want to store files, you may need to request permission:
Request App Permissions | Android Developers
Here is a how to:
An Android Storage Access Framework Example - Techtopia.
And a great working example is Ian Lake's Local Storage. Its source can be found on GitHub:
https://github.com/ianhanniballake/LocalStorage
And the app can be downloaded from Google Play:
https://play.google.com/store/apps/details?id=com.ianhanniballake.localstorage
Most android distributions do not come with a default file browser, and the behavior you noticed is the default android behavior. If there's any good third party file browser installed, it will automatically show up in that list. However it is not guaranteed that every end user will have a file browser installed. A general purpose fragment-widget can be created for this (and probably shared with others).
Look at this file picker, it's the best one I found:
I have posted a question before and got response regarding Barcode scanning in ZXing.
Currently i have run the barcode scanner app code, that is given in the source(/android/) using this post
My objective is to scan a barcode in my app. Since zxing is open source as told by the authors, i need to customize the scanner app raw code in my app. I found many files like WifiActivity and all. I dont know whether all the files are required to scan a barcode.
Now i want to extract the necessary and required files to decode using the camera captured image. Is it possible to extract the parts? If yes, can anyone help me in doing this by referring any links or steps. Thanks for all your useful posts and great responses. Sorry for my bad english.
what exactly are you trying to achieve? Do you want to edit and enhance the ZXing Source/App or want to use this library in your App for scanning.
For scanning you could invoke the activity for the scan result like following:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
try {
startActivityForResult(intent, REQUEST_CODE);
} catch (ActivityNotFoundException e) {
//Do something here
}
After scan u will receive the result in onActivityResult method:
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_CODE) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
I did something similar to this, but I only wanted the QR generation part of the zxing project. So I found the relevant call (maybe something like Bitmap b = zx.genQRCode() or whatever) and copied that java file into my project.
Compile and BAM - you get a ton of compile errors. At the point you just start copying other referenced files into your project until you don't get any more compile errors.
Don't forget to include proper attribution in your app - see this FAQ.