I have integrated Hola CDN in my android app & when I am trying to attach my ExoPlayer after connection established with Hola CDN by doing this-
if(api.is_connected())
api.attach(player.get_player(), userAgent, new TransferListener() {
#Override
public void onTransferStart() {
System.out.print("start");
}
#Override
public void onBytesTransferred(int i) {
System.out.print("start byte");
}
#Override
public void onTransferEnd() {
System.out.print("start end");
}
}, videoUrl);
,It gives this error -
java.lang.IllegalArgumentException at
com.google.android.exoplayer.util.Assertions.checkNotEmpty(Assertions.java:122)
As per my understanding & references. Getting java.lang.IllegalArgumentException means passing undesired param. In your case, Assertions.checkNotEmpty()method needs NON EMPTY String. But, getting NULL String due to something [that you need to trace out] & that's the reason your are getting above exception.
Giving you the below description,
checkNotEmpty(String string) Throws IllegalArgumentException if string
is null or zero length.
on
1]https://google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer2/util/Assertions.html
2]https://google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer2/util/Assertions.html#checkNotEmpty-java.lang.String-
If you fix this then rest of the things might work as you expect.
Related
I'm facing a issue in an app I'm developing that someone may be able to help me with.
I'm working on an app for payment machines that use Android (7.1), with it you are able to pay with credit card. The company that developed these machines offer a java sdk. Since this app is using React Native, I wrote a Native Module to connect with it. The SDK is really simple.
After the app is authenticated (done just once), All I have to do is call the doAsyncPayment method with the right parameters, and once its done, it will call the onSuccess or onError method of the listener.
When either of these methods is called, I call the callback parameter I got from the React Native side. In theory it's supposed to work, and it does, most of the time. Every once in a while, something happens that these callbacks are not called, so the client stays on the loading payment screen forever. No error is reported on sentry.
The only thing I'm thinking is that somehow the bridge is losing it? Maybe because these method runs asyncronously in the native side (another thread?), the connection is maybe lost?
I haven't been able to reproduce it, because it happens rarely and at random (I suppose).
I don't know much of Native Android, so any help is appreciated.
Here is a resumed piece of code of what's happening:
Native method being called:
#ReactMethod
public void startPayment(...other params,
Callback onErrorCallback, Callback onSuccessCallback) {
setPlugPag();
PlugPagPaymentData paymentData = new PlugPagPaymentData(paymentType, amountCents,
installmentType, installments, userReference, printReceipt);
PlugPagInitializationResult initResult = plugPag.initializeAndActivatePinpad(new
PlugPagActivationData(activationCode));
if(initResult.getResult() == PlugPag.RET_OK) {
plugPag.doAsyncPayment(paymentData, new PlugPagPaymentListener() {
PlugPagPrintResult printResult;
#Override
public void onSuccess(#NonNull PlugPagTransactionResult plugPagTransactionResult) {
if(printResult != null) {
WritableMap printResultMap = Arguments.createMap();
printResultMap.putInt("result", printResult.getResult());
printResultMap.putString("message", printResult.getMessage());
printResultMap.putString("errorCode", printResult.getErrorCode());
onSuccessCallback.invoke(TransactionResult.toRNWritableMap(plugPagTransactionResult), printResultMap);
}else {
onSuccessCallback.invoke(TransactionResult.toRNWritableMap(plugPagTransactionResult));
}
}
#Override
public void onError(#NonNull PlugPagTransactionResult plugPagTransactionResult) {
onErrorCallback.invoke(TransactionResult.toRNWritableMap(plugPagTransactionResult));
}
#Override
public void onPaymentProgress(#NonNull PlugPagEventData plugPagEventData) {
WritableMap eventDataMap = Arguments.createMap();
eventDataMap.putString("customMessage", plugPagEventData.getCustomMessage());
eventDataMap.putInt("eventCode", plugPagEventData.getEventCode());
sendEvent(Constants.EVENT_PLUG_PAG_PAYMENT_PROGRESS_CHANGED, eventDataMap);
}
#Override
public void onPrinterSuccess(#NonNull PlugPagPrintResult plugPagPrintResult) {
}
#Override
public void onPrinterError(#NonNull PlugPagPrintResult plugPagPrintResult) {
}
});
}else {
onErrorCallback.invoke(String.valueOf(initResult.getResult()));
}
}
on React native side, I just call:
startPayment(...other params, errorCallback, successCallback);
Maybe because the way the listener is instantiated?
Thanks in advance.
I am downloading a json file from storage using 'getBytes', but I want to cancel the download if it took more than 10 seconds. the method 'getBytes' returns a a 'Task' type which doesn't have a cancel method, unlike 'getFile' which returns 'FileDownloadTask' that indeed has a cancel method.
So, Is there a way to cancel the download using 'getBytes', Can I cast 'Task' to 'FileDownloadTask' ?
Edit: Here is my code :
mainStorageRef.child(UNIVERSITIES_DATA_STORAGE_PATH).getBytes(Long.MAX_VALUE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
#Override
public void onSuccess(byte[] bytes) {
String jsonData = new String(bytes, StandardCharsets.UTF_8);
...
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
FastUtils.toastAndLogConnectionFailure(context, e);
}
});
firebaser here
As far as I can see from the (closed source) implementation, the task that you get back from getBytes() is not a FileDownloadTask. It is instead a direct Task<byte[]> that is constructed by a TaskCompletionSource object. For that reason, it can't be cancelled.
Your request seems reasonable though, so I'd recommend filing a feature request to make the engineering team aware of it.
For the moment, I'd recommend using the getStream() method, which gives you a StreamDownloadTask task that can be cancelled. You can then read the stream contents into a ByteArrayOutputStream, which is pretty much what the getBytes method does internally.
I have two classes TrapCard and EquipmentCard, from which I want to make an object and pass this object through activities. I put a string and a int variable into my parcelable object. The int variable is a reference to an .svg image. And then I'm trying to get the reference from the object to load the .svg image in another activity. For TrapCard this works. But when I'm doing the excat same thing for EquiptmentCard my app crashes with E/Zygote: isWhitelistProcess - Process is Whitelisted
Constructor from EquiptmentCard:
public EquipmentCard(String cardName){
this.cardName = cardName;
switch (cardName){
case "Rope": cardPicRes = R.drawable.ic_rope;
break;
}
}
And here I'm trying to get the reference and load the image
final EquipmentCard equipCard = new EquipmentCard(cardName);
returnIntent.putExtra("card",equipCard);
returnIntent.putExtra("cardType","E");
runOnUiThread(new Runnable() {
#Override
public void run() {
imgViewCard.setImageDrawable(getResources().getDrawable(equipCard.getCardPicRes(), getApplicationContext().getTheme()));
}
});
Here same thing for TrapCard, this works
final TrapCard trapCard = new TrapCard(cardName);
returnIntent.putExtra("card",trapCard);
returnIntent.putExtra("cardType","F");
runOnUiThread(new Runnable() {
#Override
public void run() {
imgViewCard.setImageDrawable(getResources().getDrawable(trapCard.getCardPicRes(), getApplicationContext().getTheme()));
}
});
I'm doing this within the receiveDetections function from the Google mobileVisionAPI
with debugging I can see that my code runs to this line
imgViewCard.setImageDrawable(getResources().getDrawable(equipCard.getCardPicRes(), getApplicationContext().getTheme()));
and then crashes with the mentioned error in logcat.
I put this in try and catch but there is no error I receive. Thank you in advance for your time and have a nice day.
UPDATE1: I set the image in EquipmentCard to ic_spider1 and it worked. I have no clue whats wrong with ic_rope.
UPDATE2: Now i get an exception android.content.res.Resources$NotFoundException: Drawable xxx.xxx:drawable/ic_rope with resource ID #0x7f060072 but i have no clue why. I added this the same way i added spider. Delete and adding again don't work.
UPDATE3: Alright. It seems that my ic_rope.xml has a large string inside. I tried to rebuild my Project and then it shows the message string too large to encode using UTF-8. If i delete the ic_rope.xml i can rebuild without any errors.
Try replacing
imgViewCard.setImageDrawable(getResources().getDrawable(equipCard.getCardPicRes(), getApplicationContext().getTheme()));
with:
setImageResource(R.id.your_image_id)
Where is the documentation/sample for all overloads of invokeApi function for Azure Mobile Service client SDK for Android?
I found this article and tried following code, which does not work. There are no compile time or run time errors, invokeApi gets called, but it does not come back to onSuccess or onFailure. If I call invokeApi without order object, everything works as expected
PizzaOrder order = new PizzaOrder();
order.Size = "Large";
order.Flavor = "Four cheeses";
order.UserPhone = "555-555-1234";
ListenableFuture<PizzaOrderResponse> testresult = mClient.invokeApi("bookservice", order, PizzaOrderResponse.class);
Futures.addCallback(testresult, new FutureCallback<PizzaOrderResponse>() {
#Override
public void onFailure(Throwable exc) {
// failure handling code here
}
#Override
public void onSuccess(PizzaOrderResponse testresult) {
// success handling code here
}
});
One of the properties in the data object being returned by the custom API had incorrect data type. I am still not sure where the good documentation is and why custom API call did not fail but at least it is working now.
I am having problems with the Webview in Android and it's JavascriptInterfaces.
I am passing a string to the JavascriptInterface. When debugging it, I receive the correct string within my Android application. The problem: Sometimes I get an Uncaught Error: Error calling method on NPObject.
Does anybody know why?
The Interface in Java:
public class JSInterfaceGame extends JSInterface {
#JavascriptInterface
public void setShareText(String share){
shareText = share;
if(mJSInterfaceListener != null)
mJSInterfaceListener.onParametersChanged(SHARE_TEXT);
}
The initialization in the onCreateView-Method within the Fragment:
online = (WebView) rootView.findViewById(R.id.online);
online.setWebViewClient(new WISWebviewClient() {
#Override
public void onStatusChanged(final WebView view, int progress, long duration) {
//unrelated
}
});
WebSettings ws = online.getSettings();
ws.setJavaScriptEnabled(true);
ws.setUserAgentString(USER_AGENT);
ws.setCacheMode(WebSettings.LOAD_DEFAULT);
ws.setRenderPriority(WebSettings.RenderPriority.HIGH);
SharedPreferences settings = getActivity().getSharedPreferences(GameActivity.PREFERENCES, Context.MODE_PRIVATE);
mJSInterface = new JSInterfaceGame();
mJSInterface.setJSInterfaceListener(this); // Defined elsewhere in this class.
mJSInterface.setPlayerName(settings.getString(GameActivity.PREFS_PlAYERNAME, null));
online.addJavascriptInterface(mJSInterface, "JSInterface");
online.loadUrl("http://myurl.something");
Call in Javascript:
function makeShareText() {
var text = "Some text";
console.log(typeof text); // Always a string.
JSInterface.setShareText(text);
}
It happens when you try, using method called from javascript interface, to interact with UI. To solved it in this way:
class mJSInterface()
{
public void myFunction()
{
runOnUiThread(new Runnable() {
public void run() {
//Code that interact with UI
}
});
}
}
To highlight the comment from #Leog
The same error occurs if you call the native javascript function with wrong parameters
This was the source of my error
Another reason can be a RuntimeException on a WebViewCoreThread. Any exception occurred after receiving #JavascriptInterface call will be logged as NPObject error if still running on a WebView thread. Overall insufficient trace message with little clue about the problem.
Correct your issue with handling javascript interface call on a suitable thread.
Example A. (NPObject error):
#JavascriptInterface
public void jsCall() {
Log.v(TAG, "Prepared NullPointerException on "+Thread.currentThread());
String s = null;
s.length(); // This will cause NPObject error
}
Example B. (NullPointerException):
#JavascriptInterface
public void jsCall() {
new Thread(new Runnable() {
#Override
public void run() {
Log.v(TAG, "Prepared NullPointerException on " + Thread.currentThread());
String s = null;
s.length(); // This will throw NullPointerException
}
}).start();
}
Take this as an addition to #Nico.S's answer.
Operate iframe in Android 4.4 WebView may cause a similar exception(Uncaught ReferenceError: NPObject deleted), finally I find out the solution:
#Override
public void onPageFinished(final WebView view, String finishUrl) {
super.onPageFinished(view, finishUrl);
// android 4.4 may lost value of 'Android' when operating iframe
view.addJavascriptInterface(Activity.this, "Android");
}