Call USSD from background, Retrieve response and further sending request [duplicate] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Is there a way for an Android app to interact with the USSD dialog programmatically? The app runs on rooted phone and will not be published to google store (only for internal usage).
I'm aware that we can read the response of an USSD dialog (using accessibility hack). But what I'm trying to achieve here is to let the USSD dialog open and interact with it just like a normal user interact with it using the soft keyboard.
Thanks.

In the onAccessibilityEvent, you will need to first capture the input field, then fill it with your text, then click the "Send" (as explained by #lewil ngah)
AccessibilityNodeInfo source = event.getSource();
if (source != null) {
//capture the EditText simply by using FOCUS_INPUT (since the EditText has the focus), you can probably find it with the viewId input_field
AccessibilityNodeInfo inputNode = source.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
if (inputNode != null) {//prepare you text then fill it using ACTION_SET_TEXT
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,"text to enter");
inputNode.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
}
//"Click" the Send button
List<AccessibilityNodeInfo> list = source.findAccessibilityNodeInfosByText("Send");
for (AccessibilityNodeInfo node : list) {
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}

Tank Prajest tau.
For me is working fine.
in onAccessibilityEvent function, of AccessibilityService implementation
AccessibilityNodeInfo nodeInfo = event.getSource();
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText("Send");
for (AccessibilityNodeInfo node : list) {
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}

Using Accessibility service we can read the USSD responce and we can able to interact with ussd dialog box.That we can able to pass the value to USSD dialog box. For me is working fine.

Related

How to prevent url to show in web view [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Hi there I am trying to create app where I am using web view to show my google drive folder but whenever internet got disconnect in between loading the URL at that a msg comes with showing the URL information.
What can I do to prevent showing URL from users.
Is it possible to show some other msg whenever internet goes down on starting or when it goes down on after starting loading.
I have a custom HTML page that will show if something wrong happened when loading the url.
webView.setWebViewClient(new WebViewClient(){
#Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
switch(errorCode){
case ERROR_HOST_LOOKUP:
webView.loadDataWithBaseURL(null,"<YOUR OWN CUSTOM HTML PAGE TO SHOW WHEN THERE'S AN ERROR>", "text/html", "UTF-8",null);
break;
case ERROR_CONNECT:
webView.loadDataWithBaseURL(null,"<YOUR OWN CUSTOM HTML PAGE TO SHOW WHEN THERE'S AN ERROR>", "text/html", "UTF-8",null);
break;
case ...[IF YOU WANT TO CATCH MORE ERRORS]
}
}
}
Reference: https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20int,%20java.lang.String,%20java.lang.String)
Error Code Reference:
https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_AUTHENTICATION
Yes! You can either print the message or redirect the user to some other activity by checking the following method soon after the app gets launches...
DD4YouConfig dd4YouConfig = new DD4YouConfig(context);
if (dd4YouConfig.isInternetConnectivity()) {
//redirect to webview
}
else
{
//call alert dialog stating no internet
}
This is a library function so obviously don't fail to add this line in Gradle
implementation 'in.dd4you.appsconfig:appsconfig:1.3.3'

Country Holiday list [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
The requirement is to choose a country from a dropdown and display the list of holidays for the country chosen. Please let me know if there are any APIs that accomplish this.
You don't need to use any third party API for it, you can do it with google Calendar API like this
com.google.api.services.calendar.Calendar client = null;
credential = GoogleAccountCredential.usingOAuth2(mContext, CalendarScopes.CALENDAR);
credential.setSelectedAccountName(mList.get(0));
client = getCalendarService(credential);
do {
com.google.api.services.calendar.model.Events events;
events = client.events().list("en.usa#holiday#group.v.calendar.google.com").setPageToken(pageToken).execute();
onHolidayChecked(events.getItems()); //result return here (events.getItems())
pageToken = events.getNextPageToken();
} while (pageToken != null);
private com.google.api.services.calendar.Calendar getCalendarService(GoogleAccountCredential credential) {
return new com.google.api.services.calendar.Calendar.Builder(AndroidHttp.newCompatibleTrans port(), new GsonFactory(), credential).build();
}
Only solution I found is that to either add it statically in your string.xml
or
Try this API which google provides
1) Register a project at https://code.google.com/apis/console
2) Generate a Simple API Access key
3) Ensure Calendar API is activated under services.
Read more at https://developers.google.com/google-apps/calendar/firstapp
checkout this sample

Sending mail from Third party sites Programmatically [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
How can I send mail from sites other than gmail, hotmail, rediffmail. Without any API provided. Is there provision to make this happen in any of programming languages. I think the domain I'm going to use does not have any captcha checks.
I also would like to attach a folder within.
If you are asking about other domain names, like your own domain then you can use below method:
Add using System.Net.Mail;
then below in some event
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("mail.yoursite.com");
mail.From = new MailAddress("testing#yoursite.com");
mail.To.Add("youremail#address.com");
mail.Subject = "New Email";
mail.Body = "add text here from controls";
SmtpServer.Port = 25;
SmtpServer.Credentials = new System.Net.NetworkCredential("testing#yoursite.com", "passhere");
SmtpServer.EnableSsl = false;
SmtpServer.Send(mail);
MessageBox.Show("All Done");

FaceBook ShareLinkContent setImageUrl image is overriden by setContentUrl meta-data image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to Post the below infromation to FaceBook from Myapp using FaceBook ShareLinkContent class
- link url (using SetContentUrl method)
- image (using setImageurl method)
- hashtags (using setHashTag method)
- and Description
as like
ShareHashtag shareHashTag = new ShareHashtag.Builder().setHashtag(hashtag_name).build();
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setImageUrl(Uri.parse(selectedImagePath))
.setShareHashtag(shareHashTag)
.setContentDescription(textd)
.setContentUrl(Uri.parse(linkUrlPath))
.build();
shareDialog.show(linkContent);
}
} else {
shareImage();
}
The question is, instead of posting the image from "selectedImagePath" url, it post the meta-data image coming from the "linkUrlPath" url.
How to overcome it, so that i can post the image which i send in the method setImageUrl() method.
note: I am using Facebook SDK 4.14.1
Kindly provide suggestions
I guess this is what you are looking for -
Template Matching
Template Matching is a method for searching and finding the location of a template image in a larger image. OpenCV comes with a function matchTemplate() for this purpose. It simply slides the template image over the input image (as in 2D convolution) and compares the template and patch of input image under the template image.

NFC Mifare Ultralight tags writing [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Any tutorial for how to write on Mifare Ultralight tags ?
I have been searching for a while
MifareUltraLight tags it contains 16 page and each page contains 4 bytes. Its first 4 page contains manufacturer info , OTP and locking bytes.
After getting The Tag you can get MifareUltralight class using this:
MifareUltralight mifare = MifareUltralight.get(tag);
When you get the tag then before read and write into a page you must have to connect. When Connect successfully then using this Command you can write:
mifare.writePage(pageNumber, pageData.getBytes("US-ASCII"));
here pageNumber is the page where you want to write and page data is Data that you want to write. pageData must be equals 4 bytes and page Number must less than 16.
The Complete Code is here:
public void writeOnMifareUltralightC( Tag tag,
String pageData, int pageNumber) {
MifareUltralight mifare = null;
try {
mifare = MifareUltralight.get(tag);
mifare.connect();
mifare.writePage(pageNumber, pageData.getBytes("US-ASCII"));
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
mifare.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
You can also see the code sample From my repository
You might want to look at this StackOverflow question:
Writing NFC tags using a Nexus S
Also, if you haven't done so already, read through the NFC Basics document on the Android developers' site:
http://developer.android.com/guide/topics/nfc/nfc.html
(Admittedly, there's not much documentation out there on this yet. If you get this working, I'd encourage you to write a technical blog post on your experiences!)

Categories