Unable to read data in AWS android mobile while using DynamoDB - android

I started to develop an android app using Amazon Mobile hub (my first time) and Android Studio 3.0.1, and I tried to follow the tutorials
But I keep on getting errors like:
com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMappingException: No method annotated with interface com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBRangeKey for class class com.amazonaws.models.nosql.ParkInfoDO.
I have a
table park_info
partition key:park_id
Is there something wrong with my code?
public void readData() {
final IdentityManager identityManager = IdentityManager.getDefaultIdentityManager();
new Thread(new Runnable() {
#Override
public void run() {
ParkInfoDO parkItem = dynamoDBMapper.load(
ParkInfoDO.class,
identityManager.getCachedUserID(),
"P");
// Item read
Log.d("Park Item:", parkItem.toString());
}
}).start();
}

Related

Add Apptentive Survey for Android

From the Android Apptentive documentation, only get a callback when a Survey is finished:
Apptentive.setOnSurveyFinishedListener(new OnSurveyFinishedListener() {
#Override
public void onSurveyFinished(boolean completed) {
// Your code
}
});
But,I want to get some class like ios:
ApptentiveSurveyShownNotification/ApptentiveSurveySentNotification
This way I can get more content than just completed(true/false).
Is there such some class for Android Apptentive?

Incomings Call with Android Sip stack in Embarcadero C++ builder

I'm trying to receive calls on my SIP application at Embarcadero with C++ builder
and I'm not able to get it. My situation is as follows:
I've made an Asterisk server, I've created several accounts to be able to do the
tests and I've downloaded the Zoiper application for both Windows and Android.
In my designed application, I'm able to make calls to those accounts registered
in Zoiper, although not through events, it seems that the listener does not
listen, and I've done it through the status changes in the call.
The Java code is like this:
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
#Override
public void onCallEstablished(SipAudioCall call) {
call.startAudio();
call.setSpeakerMode(true);
call.toggleMute();
Log.d("on call established", "on call established");
}
#Override
public void onCallEnded(SipAudioCall call) {
finish();
}
};
In Embarcadero C++ builder I think it would be like this (it doesn't work)
Compiles and executes but the event never occurs:
//The Manifest counts as the necessary permissions for Android, Internet and Sip.
_di_JSipAudioCall_Listener audioCall_Listener;
_di_JSipSession_Listener sessionListener;
_di_JSipSession session;
_di_JSipManager;
_di_JSipAudioCall audioCall;
_di_JSipProfile profile;
_di_JString uri;
_di_JString uri_llamada;
void onCallEstablished2(SipAudioCall call);
//The process of profile creation and instantiation of SipManager are programmed
//and compiled and do not give any problem.
audioCall_listener = TJSipAudioCall_Listener::JavaClass->init();
audioCall_listener->onCallEstablished = onCallEstablished2;
sessionListener = TJSipSession_Listener::JavaClass->init();
session = manager->createSipSession(profile,sessionListener);
audioCall = manager->makeAudioCall(uri,uri_llamada,audioCall_listener,15);
void onCallEstablished2(SipAudioCall call)
{
audioCall->startAudio();
audioCall->setSpeakerMode(true);
}
The code made in Embarcadero C++ builder that works:
//The Manifest counts as the necessary permissions for Android, Internet and Sip.
_di_JSipAudioCall_Listener audioCall_Listener;
_di_JSipSession_Listener sessionListener;
_di_JSipSession session;
_di_JSipManager;
_di_JSipAudioCall audioCall;
_di_JSipProfile profile;
_di_JString uri;
_di_JString uri_llamada;
//The process of profile creation and instantiation of SipManager are programmed
//and compiled and do not give any problem.
audioCall_listener = TJSipAudioCall_Listener::JavaClass->init();
audioCall_listener->onCallEstablished = onCallEstablished2;
sessionListener = TJSipSession_Listener::JavaClass->init();
session = manager->createSipSession(profile,sessionListener);
audioCall = manager->makeAudioCall(uri,uri_llamada,audioCall_listener,15);
Timer1->Enabled = true;
void __fastcall TMainForm::Timer1Timer(TObject *Sender)
{
if (audioCall->getState() == 8)
{
audioCall->startAudio();
audioCall->setSpeakerMode(true);
}
if(audioCall->getState() == 0)
{
audioCall->endCall();
}
}
As for the Java code for receiving calls, I have found examples here
No ringing event on incoming calls
and here
Android Sip incoming Call using Service with Broadcast Receiver,
but they are all event based, which doesn't seem to work for me.
I have also tried to do the IncomingReceiver class, which extends from
BroadcastReceiver and at the Embarcadero gives me problems.
Class made in Embarcadero with C++ builder (not compiles):
class IncomingReceiver: public JBroadcastReceiver{
public:
__fastcall IncomingReceiver();
_di_JSipAudioCall incomingCall;
void onReceive(_di_JContext contexto, _di_JIntent intento);
void accept();
void showIncomingCallGui(_di_JIntent intento, _di_JContext contexto);
};
So, my questions are:
Why don't events work for me?
Can I receive calls without events?
If so, what would it be like without events?
What do I do if I can't get the IncomingReceiver class?
I found a page (in spanish): http://lfgonzalez.visiblogs.com/cbuilder-10-2-tokyo-jni-broadcastreceiver-android/ in which it is explained the use of BroadcastReceiver in Embarcadero C++ Builder. Maybe with this information you can get the events working in order to receive calls.

OneDrive SDK for android, cannot login silently

I have a standalone Java application that uses a OneDrive Java API I found on github. Everything works nicely.
So I already have a clientid, a client secret, an authorization code and a refresh token which work flawlessly
Now I wanted to switch over to Android, but I wasn't successfull in using the same Java API. That's why I wanted to move to the official OneDrive Android SDK provided by Microsoft.
Everything seems to be different there. I tried the following, using my already known clientid
final Activity me = this;
final MSAAuthenticator msaAuthenticator = new MSAAuthenticator() {
#Override
public String getClientId() {
return clientid;
}
#Override
public String[] getScopes() {
return new String[] { "onedrive.appfolder" };
}
};
final IClientConfig oneDriveConfig = DefaultClientConfig.createWithAuthenticator(
msaAuthenticator);
final IOneDriveClient oneDriveClient = new OneDriveClient.Builder()
.fromConfig(oneDriveConfig)
.loginAndBuildClient(me);
oneDriveClient
.getDrive()
.buildRequest()
.get(new ICallback<Drive>() {
#Override
public void success(final Drive result) {
final String msg = "Found Drive " + result.id;
Toast.makeText(me, msg, Toast.LENGTH_SHORT)
.show();
}
#Override
public void failure(ClientException ex) {
final String msg = "Error";
Toast.makeText(me, msg, Toast.LENGTH_SHORT)
.show();
}
});
It ends up in a seemingly endless loop while executing the line .loginAndBuildClient(me)
In logcat I see that it suppressed an Exception
07-13 12:32:17.082 28175-28271/org.xxxxxxx.xxxxxxxxx E/MSAAuthenticator$5[onAuthComplete] - 314:
Failed silent login, interactive login required
com.onedrive.sdk.authentication.ClientAuthenticatorException: Failed silent login, interactive login required
at com.onedrive.sdk.authentication.MSAAuthenticator$5.onAuthComplete(MSAAuthenticator.java:312)
There are also some info messages:
07-13 12:32:17.079 28175-28271/org.xxxxxxx.xxxxxxxxx I/LiveAuthClient:
No refresh token available, sorry!
07-13 12:32:17.079 28175-28271/org.xxxxxxx.xxxxxxxxx I/LiveAuthClient:
All tokens expired, you need to call login() to initiate interactive logon
Obviously it somehow wants to perform an interactive login and fails terribly.
What I don't understand: I already have a perfectly valid refresh token which I want to reuse, but I did not find a way to do it in the MS OneDrive SDK.
Can someone help me here?
This post is a little old, but i wanted to share my solution to help others.
Instead of using this method "loginAndBuildClient" with only the Activity parameter, like this :
final IOneDriveClient oneDriveClient = new OneDriveClient.Builder()
.fromConfig(oneDriveConfig)
.loginAndBuildClient(me);
Declare a global OneDriveClient:
private IOneDriveClient mOneDriveClient;
Then use the "loginAndBuildClient" method with the Callback parameter. And assign your OneDriveClient in the "success" method :
new OneDriveClient.Builder()
.fromConfig(DefaultClientConfig.createWithAuthenticator(msaAuthenticator))
.loginAndBuildClient(MainActivity.this, new ICallback<IOneDriveClient>() {
#Override
public void success(IOneDriveClient iOneDriveClient) {
mOneDriveClient = iOneDriveClient;
}
#Override
public void failure(ClientException ex) {
mOneDriveClient = null;
}
});
I managed to implement access to the OneDrive API manually (without using the SDK) and it worked
Turns out I "only" forgot to set INTERNET permission for the app. Really strange that it caused my app to fail silently.

How to pass realm in AutobahnConnection android?

I am using AutobahnConnection for ws communication. I have created the object of AutobahnConnection and passed the wsUri but I am unable to find a way to pass "realm" with it. It is compulsory for me to pass it. I have explored lot of places but I am unable to find any solutions. Here is my code
private final AutobahnConnection mConnection = new AutobahnConnection();
private void start() {
final String wsUri = "ws://xxx.xxx.xxxx/ws";
mConnection.connect(wsUri, new Autobahn.SessionHandler() {
#Override
public void onOpen() {
testRpc();
testPubSub();
}
#Override
public void onClose(int code, String reason) {
Log.d(TAG, "calc:add result = " + reason);
}
});
}`
I am getting Protocol Voilation Error as I am ubable to pass realm. Any help will be highly appreciated.
What are you trying to connect to? AutobahnAndroid only does WAMP v1, which is incompatible with WAMP v2. To connect to v2 routers from Android, you may want to take a look at https://github.com/Vinelab/Android-wamp-client.

PayPal.initWithAppID() crashes with NullPointerException

FATAL EXCEPTION: Thread-5195
java.lang.NullPointerException: src == null
at java.lang.System.arraycopy(Native Method)
at com.paypal.android.a.g.a(Unknown Source)
at com.paypal.android.a.h.c(Unknown Source)
at com.paypal.android.MEP.PayPal.setLanguage(Unknown Source)
at com.paypal.android.MEP.PayPal.initWithAppID(Unknown Source)
at com.lonfun.pets.UnityPayMenuActivity.initLibrary(UnityPayMenuActivity.java:256)
at com.lonfun.pets.UnityPayMenuActivity.access$2(UnityPayMenuActivity.java:249)
at com.lonfun.pets.UnityPayMenuActivity$2$1.run(UnityPayMenuActivity.java:175)
I just use android to open paypal, everything is ok, but if I call from unity, this is happened!
this is my java code:
package com.paypal.androidpets;
import android.content.Context;
import android.os.Handler;
import com.lonfun.pets.UnityPayMenuActivity;
import com.paypal.android.MEP.PayPal;
import com.paypal.android.MEP.PayPalActivity;
public class PaypalTool {
Context context;
PayPal pp;
private static final int server = PayPal.ENV_SANDBOX;
// The ID of your application that you received from PayPal
private static final String appID = "APP-80W284485P519543T";
public PaypalTool(Context context) {
this.context=context;
}
public void initLibrary(final Handler handler)
{
new Thread() {
public void run() {
PayPalActivity._paypal = null;
pp = PayPal.getInstance();
// If the library is already initialized, then we don't need to initialize it again.
if(pp == null) {
// pp = PayPal.initWithAppID(context, "", PayPal.ENV_NONE);
pp = PayPal.initWithAppID(context, appID, server);
pp.setShippingEnabled(false);
}
if (PayPal.getInstance().isLibraryInitialized()) {
handler.sendEmptyMessage(0);
}
else {
handler.sendEmptyMessage(1);
}
}
}.start();
}
}
has anybody solve this problem,,please help me, thank you!
using UnityEngine;
using System.Collections;
public class PayMoneyHandler : MonoBehaviour
{
#if UNITY_ANDROID
static AndroidJavaClass payPluginClass;
static AndroidJavaClass unityPlayer;
static AndroidJavaObject currActivity;
#endif
public static void Pay(string productID)
{
#if UNITY_ANDROID
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
jo.Call("StartActivity0",
"com.peten.tier2",
"EGAHCNJDEJBWBIBWEXIKDEGLJECOAD.Mac",
"Dog",
"AndDogCn",
"http://42.121.94.123/TradeWeb/AlipayTrade.aspx",
"http://58.246.188.238/TradeWeb/PaypalTrade.aspx"
);
#endif
}
}
using UnityEngine;
using System.Collections;
public class TestForPaypal : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void OnClick(){
Debug.Log("Test For Paypal!");
PayMoneyHandler.Pay("test1");
}
}
public void StartActivity0(final String name,final String PlayerName,final String GameID,final String ZoneID,final String payUrl,final String paypalUrl)
{
this.runOnUiThread(new Runnable() {
#Override
public void run() {
Log.i("Order", "name:"+name+"PlayerName:"+PlayerName+"GameID:"+GameID+"ZoneID:"+ZoneID+"payUrl:"+payUrl+"paypalUrl:"+paypalUrl);
Intent payintent=new Intent(mContext,UnityPayMenuActivity.class);
payintent.putExtra("name",name);
payintent.putExtra("PlayerName",PlayerName);
payintent.putExtra("GameID",GameID);
payintent.putExtra("ZoneID",ZoneID);
payintent.putExtra("payUrl",payUrl);
payintent.putExtra("paypalUrl",paypalUrl);
Unity3DMainActiviy.this.startActivity(payintent);
}
});
}
I think you didnot enter the appID and the server detail.
Below is the working code which i have implement and It works fine for me.
I have implement Pay on button click which extends the runnable
Check_out.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (_paypalLibraryInit) {
showPayPalButton();
//Toast.makeText(Android_PP_Test1Activity.this, captions[position], Toast.LENGTH_SHORT).show();
}
else {
// Display a progress dialog to the user and start checking for when
// the initialization is completed
Thread initThread = new Thread(initLibraryRunnable);
initThread.start();
_progressDialog = new ProgressDialog(Recharge.this);
_progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
_progressDialog.setMessage("Loading PayPal Payment Library");
_progressDialog.setCancelable(false);
_progressDialog.show();
_progressDialogRunning = true;
Thread newThread = new Thread(checkforPayPalInitRunnable);
newThread.start();
//Toast.makeText(Android_PP_Test1Activity.this, "Picasso Paintings", Toast.LENGTH_SHORT).show();
}
}
});
This button call this runnable method
//This lets us run the initLibrary function
final Runnable initLibraryRunnable = new Runnable() {
public void run() {
initLibrary();
}
};
and this method is responsible to initiate the initLibrary.
/** init method **/
public void initLibrary() {
PayPal pp = PayPal.getInstance();
if (pp == null) {
// This is the main initialization call that takes in your Context,
// the Application ID, and the server you would like to connect to.
pp=PayPal.initWithAppID(this,"APP80W284485P519543T",PayPal.ENV_SANDBOX);
// -- These are required settings.
pp.setLanguage("en_US"); // Sets the language for the library.
// --
// -- These are a few of the optional settings.
// Sets the fees payer. If there are fees for the transaction, this
// person will pay for them. Possible values are FEEPAYER_SENDER,
// FEEPAYER_PRIMARYRECEIVER, FEEPAYER_EACHRECEIVER, and
// FEEPAYER_SECONDARYONLY.
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
// Set to true if the transaction will require shipping.
pp.setShippingEnabled(true);
// Dynamic Amount Calculation allows you to set tax and shipping
// amounts based on the user's shipping address. Shipping must be
// enabled for Dynamic Amount Calculation. This also requires you to
// create a class that implements PaymentAdjuster and Serializable.
pp.setDynamicAmountCalculationEnabled(false);
// --
}
}
Hope It helps...
The problem is when unity generates the apk file. I have compared one apk i made miself with PayPal integration only compiling with eclipse and other compiling with Unity.
Lets say the apk i made only with eclipse is called "PayPalOnlyEclipse.apk" and the one made with unity "PayPalWithUnity.apk"; y renamed them to "PayPalOnlyEclipse.zip" and "PayPalWithUnity.zip", then open both with WinRar to compare them.
I found that PayPalOnlyEclipse had one folder that PayPalWithUnity didn't, the folder is "com\paypal\android\utils\data". So I decompressed that folder and then added it to PayPalWithUnity. Then erase the META-INF folder (the signing), then close the "PayPalWithUnity.zip" and rename it like it was before ("PayPalWithUnity.apk").
Then I used the command for signing the apk file:
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore my.keystore PayPalWithUnity.apk user
Finally I used the command for zipalign:
zipalign -v 4 PayPalWithUnity.apk PayPalWithUnity2.apk
that command generates PayPalWithUnity2.apk and that is the apk file you have to install in your phone.
Hope it helps, and sorry for my english.
Check if you have included the PaypalActivity on manifest file. Like this:
<activity android:name="com.paypal.android.MEP.PayPalActivity"
android:configChanges="keyboardHidden|orientation" />
If you have it and it doesnt work yet, include the library on the build path (Properties>>Java Buid Path>>Libraries>>Add JARs) and add it on the "order and export" tab (Properties>>Java Buid Path>>Order and Export).

Categories

Resources