GmailQuickstart modification for android - android

I am trying to implement this in android.
https://github.com/googleworkspace/java-samples/blob/master/gmail/quickstart/src/main/java/GmailQuickstart.java
few questions :
private static final String APPLICATION_NAME = ... is this the android app name?
what is the alternative for this in android :
private static final String TOKENS_DIRECTORY_PATH = "tokens";

full description and working solution is here
Use Gmail api for send mail via Android app
basically you need to change few things:
browser Call (within the auth function) to intent.
and remove all UI calls from do in background process.

Related

NFC-tag password protection with ST25 android SDK

I'm working with ST25 tags, more specifically type5 tags ST25DV64K. The ST25 SDK for android has some interesting examples and tutorials in it. I'm still struggling to use the code example provided at the end of the doc here concerning password-protected data, which consist in those lines:
byte[] password;
int passwordNumber = type5Tag.getPasswordNumber(area);
tag.presentPassword(passwordNumber, password);
NDEFMsg ndefMsg = myTag.readNdefMessage(area);
first problem, when I instanciate a type5 tag i don't see those methods for Type5Tag class:
import com.st.st25sdk.type5.*;
Type5Tag tag5;
tag5.??
Then, it is not clear how we are supposed to set up a password in the first place. I can't find any examples of setting up a password for a specific area, and removing it, and what is the format of the password that we can use? Is it possible to do this from android or do we have to use the ST25 app? Examples welcome! Thanks.
In the ST25 SDK Zip file, you will find an example of a basic Android App using the ST25 SDK Library (it is in \integration\android\examples\ST25AndroidDemoApp).
This example uses a class called “TagDiscovery” which is able to identify any ST25 Tag and to instantiate the right object. In your case, if you are only using ST25DV64K Tags, you will probably want to do something simple.
Here is what I suggest you:
In your android activity, I expect that you have subscribed to receive a notification every time an NFC tag is taped (in “ST25AndroidDemoApp” example, look at enableForegroundDispatch() in onResume() function).
To identify if the Intent corresponds to an “NFC Intent”, we check if the Intent’s Action is ACTION_NDEF_DISCOVERED, or ACTION_TECH_DISCOVERED or ACTION_TAG_DISCOVERED.
When this is the case, we know that it is an NFC Intent. We can then call this to get the instance of androidTag:
Tag androidTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
This object represents the current NFC tag in Android.
We’re now going to instantiate a ST25DVTag object.
import com.st.st25sdk.type5.st25dv.ST25DVTag;
…
AndroidReaderInterface readerInterface = AndroidReaderInterface.newInstance(androidTag);
byte[] uid = androidTag.getId();
uid = Helper.reverseByteArray(uid);
ST25DVTag myST25DVTag = new ST25DVTag(readerInterface, uid);
You now have an object called myST25DVTag that can be used to communicate with the tag!
For example, if you want to use the passwords:
byte[] password = new byte[]; // TODO: Fill the password
int passwordNumber = myST25DVTag.getPasswordNumber(area);
myST25DVTag.presentPassword(passwordNumber, password);
NDEFMsg ndefMsg = myST25DVTag.readNdefMessage(area);
Before doing that, you need to check which password is associated to this area. The tag has 3 passwords that can be freely assigned to any area. By default no password is set so you should set one. Here is an example where I use the password 2 for Area1:
int AREA1 = 1;
int passwordChosen = 2;
myST25DVTag.setPasswordNumber(AREA1, passwordChosen);
I suggest that you install the ”ST25 NFC Tap” Android App from Google Play: https://play.google.com/store/apps/details?id=com.st.st25nfc&hl=fr&gl=US
If you tap you ST25DV and go to the “Areas Security Status” menu, you will be able to see: the number of areas, which ones are protected by password for read and/or write, which password is used…etc
If you are interested, the source code of this application is available here: https://www.st.com/en/embedded-software/stsw-st25001.html
Tell me if something is unclear.
Disclaimer: I am on of the development team for the ST25 SDK.

Cannot find getContext() as per Android dedicated device documentation

I know a similar question has been asked several times before but I have been through those and they do not help me.
I am trying to set up a Samsung Tab A (Android 8.1) as a single-use device. I have already written the app which works perfectly but as the device will be used by the public I need to lock it down into kiosk mode.
I am trying to follow the developer guide at the link below but immediately hit problems.
https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode
So first thing I try to do is whitelist the app as per the example given:
// Whitelist two apps.
private static final String KIOSK_PACKAGE = "com.example.kiosk";
private static final String PLAYER_PACKAGE = "com.example.player";
private static final String[] APP_PACKAGES = {KIOSK_PACKAGE, PLAYER_PACKAGE};
// ...
Context context = getContext();
DevicePolicyManager dpm =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName adminName = getComponentName(context);
dpm.setLockTaskPackages(adminName, APP_PACKAGES);
The documentation is not clear on where this code should go but I have put it in an override for onResume().
I am using auto-import in Android Studio but it tells me that getContext() cannot be found. I have tried changing to getApplicationContext() and just using this as suggested elsewhere but then it complains that getComponentName() should not have any parameters. I have tried simply removing the context parameter, using context.getComponentName() and also using no context variables. These compile but the app crashes on the device (at setLockTaskPackages()).
I suspect that the key is to find out why getContext() cannot be found and then hopefully everything else falls into place. Any idea what might be missing?
If you're using activity use the keyword this, instead of getContext.
getContext() is used in fragment to get context.Is this is Activity,You can use Yourclass.this or this. also you can get knowladge about what can you use for context using this

admob run on test device but when i run on real time it shows failed to load native add:0 , my app id created 3-4 days ago

private static final String ADMOB_AD_UNIT_ID = "ca-app-pub-6965669387020729/3235162894";
private static final String ADMOB_APP_ID = "ca-app-pub-6965669387020729~1758429698"
adLoader.loadAd(new AdRequest.Builder().build());
You need to do following steps and check
Check if Admob Id is correct or not.
You can add a adListner() to check if any error code and check it.
If you get any error , you can search it on google.
If not you can create a new id with different package name and use it as some time unwanted clicks can cause problems(refer admob docs).
All the best.

How to read RCS messages from android device programmatically

My application basically backup the SMS and MMS to cloud server. I used below URI to retrieve data from database.
SMS- Uri uri = Uri.parse("content://sms/");
MMS-Uri uri = Uri.parse("content://mms/");
Few days back while testing my app i noticed some messages(SMS & MMS) are missing while retrieving from SQLite. After doing some research i found that those are RCS (Rich Communication Services) messages. Now my challenge is to read RCS messages(SMS & MMS).
Is there any way to read RCS (Rich Communication Services) messages in Android?
What URI i need to use for read RCS (Rich Communication Services) messages?
Thanks in advance.
EDIT: It seems like the API won’t make it after all. Work is still happening to it apparently: https://android-review.googlesource.com/q/RCS+(status:open+OR+status:merged). But it won’t be for third-party developers.
According to this (https://9to5google.com/2019/02/22/android-q-rcs-api-delay/), now there will be no developer-accessible API for RCS messages until Android R at the earliest.
There isn’t a way (short of some vendor-specific API) at the moment, but support for programatically interfacing with RCS is underway if the code commits are any indication of the direction Android is going… https://android-review.googlesource.com/c/platform/frameworks/base/+/849669
The relevant classes are still being implemented, but it looks like you’ll be relying on these (tentatively):
RcsParticipant
RcsThread
Rcs1To1Thread (extends RcsThread)
RcsGroupThread (extends RcsThread)
RcsMessage
RcsIncomingMessage (extends RcsMessage)
RcsOutgoingMessage (extends RcsMessage)
RcsPart
RcsFileTransferPart (extends RcsPart)
RcsLocationPart (extends RcsPart)
RcsMultiMediaPart (extends RcsPart)
RcsTextPart (extends RcsPart)
This code is telling:
class RcsThreadQueryHelper {
static final String ASCENDING = "ASCENDING";
static final String DESCENDING = "DESCENDING";
static final String THREAD_ID = "_id";
static final Uri THREADS_URI = Uri.parse("content://rcs/thread");
static final Uri PARTICIPANTS_URI = Uri.parse("content://rcs/participant");
static final String[] THREAD_PROJECTION = new String[]{THREAD_ID};
static String buildWhereClause(RcsThreadQueryParameters queryParameters) {
// TODO - implement
return null;
}
}

Where to add #SdkConstant?

Evening all, I have an android device with an SOS button on it (hardware) I am trying to set it up so that it calls up a test application I have created purely as a proof of concept.
This is the information I have been provided by the manufacturer
// Add for SOS/PTT Key Start
#SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_EXT_PTTDOWN = "com.TMZP.Main.PTTDown";
#SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_EXT_PTTUP = "com.TMZP.Main.PTTUp";
#SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_EXT_SOSDOWN = "com.TMZP.Main.SOSDown";
#SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_EXT_SOSUP = "com.TMZP.Main.SOSUp";
// Add for SOS/PTT Key End
Please NOTE:
Both the PTT up and PTT down intent are useful.
int ACTION_DOWN getAction() value: the key has been pressed down.
int ACTION_UP getAction() value: the key has been released.
The problem is, I don't know what to do with the #SdkConstant, I've never seen it before and cant seem to find any explanation.
Currently I have simply added the following intent filter to my test activity, however pressing the hardware button produces no result.
<intent-filter>
<action android:name="com.TMZP.Main.SOSDown"/>
</intent-filter>
Any insight into where I add the #SdkContant would be really helpful (or simply pointing me towards some reading material.)
Thanks in advance.
#SdkConstant, AFAIK, is from the Android OS source code itself, or things built into a revised version of that OS.
For your purposes, just comment them out.
Currently I have simply added the following intent filter to my test activity, however pressing the hardware button produces no result.
That is because, based on the #SdkConstant lines, those are used for broadcasts, not starting activities. Try implementing a BroadcastReceiver that listens for them.

Categories

Resources