<-- operator in android graphics - android

v1.addView(new TransfomedViewWidget(<-- (9)
this,
new Transformation() {<-- (10)
#Override public String describe() { return "rotate(-30)"; }
#Override public void transform(Canvas canvas) {
canvas.rotate(-30.0F);
} }));
I am new to Java and android programming , can anyone tell me what this <-- operator means? I am getting error while trying to compile this in eclipse.

It isn't part of the syntax, it loks like something else has put it there.

Certainly it was a note or comment ... add // in front of them and try to compile again.

Related

Unity Admob plugin; The application crashes when you try to change "TextMesh.text"

1) I used the sample project on https://github.com/googleads/googleads-mobile-unity
2) I added a "TextMesh" object to the scene (Game object name: "Screen Text").
3) I have added the following lines;
public class GoogleMobileAdsDemoScript : MonoBehaviour
{
TextMesh screenText;
...
...
public void Start()
{
screenText = GameObject.Find("Screen Text").GetComponent<TextMesh>();
...
...
public void HandleRewardBasedVideoClosed(object sender, EventArgs args)
{
screenText.text = "Test 1";
...
...
public void HandleRewardBasedVideoRewarded(object sender, Reward args)
{
screenText.text = "Test 2";
...
...
4) When the video is finished or canceled, I'm trying to change the text and the app is always crashes.
5) Unity Version: Unity 2017.3.1f1 (64-bit). Android SDK: Platform 27. Phone Note 5
Is this an issue? or do I have to fix something?
(Here is Log file when video rewarded: https://justpaste.it/7b1hn)
For future reference, yes, it happens regularly. It's not a simple missing reference issue.
I have also tried creating a Canvas with just an Image: no crash.
Then I have tried creating a Canvas with just a TextMeshPro text: CRASH!
The simplest fix I have found (after many many hours of tests) was to "change the text" one frame later, through a very simple coroutine starting with "yield return new WaitForEndOfFrame()".
I'm still reading and investigating, and will update here if I find anything.
Have you tried adding check for screenText? Try this.
if (screenText != null)
screenText.text = "Test 2";
else
Debug.Log ("NULL screenText");

Scichart can't remove annotation

When Im trying to remove an annotation, I’m receiving an error:
java.lang.NullPointerException: Attempt to invoke interface method
‘void
com.scichart.charting.visuals.annotations.IAnnotationPlacementStrategy.drawAdorner(android.graphics.Canvas)’
on a null object reference at
com.scichart.charting.visuals.annotations.AnnotationBase.onDrawAdorner(SourceFile:889)
at
com.scichart.charting.visuals.annotations.AdornerLayer.onDraw(SourceFile:144)
at android.view.View.draw(View.java:17071) at
android.view.View.updateDisplayListIfDirty(View.java:16053)
I’ve tried many ways, like:
UpdateSuspender.using(priceChart, new Runnable() {
#Override
public void run() {
priceChart.getAnnotations().clear();
}
});
and
UpdateSuspender.using(priceChart, new Runnable() {
#Override
public void run() {
priceChart.getAnnotations().remove(myAnnotation);
}
});
But I just can't remove it.
That's weird. There's a SciChart Android Tutorial on Annotations here. It uses 'chart.getAnnotations().remove(0)'
The full source code for this tutorial can be found at the SciChart.Android.Examples Github repository.
Does it work for you?
this is the official answer from Scichart team:
Hi Marcos,
I want to notify you that I’ve investigated and fixed this issue. It
was caused by a small bug in our code – when you remove annotation
from chart it doesn’t remove adorner for annotation if it is selected.
The fix will be available in our next nightly build and for now you
can workaround this issue by unselecting annotation before removing
from collection:
UpdateSuspender.using(priceChart, new Runnable() {
#Override
public void run() {
myAnnotation.setSelected(false);
priceChart.getAnnotations().remove(myAnnotation);
}
});
Hope this will help you!
Best regards,
Yura

crashlyticsDidDetectCrashDuringPreviousExecution for crashlytics NDK

We are using crashlyticsDidDetectCrashDuringPreviousExecution to detect java crashes and report them to our BI systems, but our app is mostly C++ and we are using crashlytics NDK, we can't find anything similar to crashlyticsDidDetectCrashDuringPreviousExecution.
Is there any way that we can actually detect an NDK crash when the app starts?
thanks
Oded
Mike from Fabric here.
Currently, there isn't a way to do this within Fabric or the SDK for an NDK crash.
NOTE: This works on older version only (Crashlytics 2.6.7 and CrashlyticsNDK 1.1.6)
I'm also looking for a solution for this.
We currently found a partial solution. I'm not sure how good it is, it's definitely not official, plus it's asynchronic (which we're trying to overcome by looping), but it's the best solution I found and it seems like it's working
Fabric.with(this, new Crashlytics.Builder().core(core.build()).build(), new CrashlyticsNdk(), new Crashlytics());
if (!userLeft) { // our handling to fix bug, see explanation below
new Thread(new Runnable() {
#Override
public void run() {
SessionEventData crashEventData = null;
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(1000); // in ms
} catch (InterruptedException e) { }
crashEventData = CrashlyticsNdk.getInstance().getCrashEventData();
if (crashEventData != null)
{
// there was a crash!
// crash timestamp can be found at crashEventData.timestamp
break;
}
}
}
}).start();
}
Explaination for userLeft:
We had some bug with reporting crash for users that exited app, and this is the solution for that. We set this flag to true, and save it on the device (SharedPreferences). We do it on our main activity (which extends NativeActivity), on finish() func.
Code:
#Override
public void finish() {
// set some key such as USER_LEFT to TRUE
super.finish();
}
After that, just get that USER_LEFT value, assign it into userLeft param, and set it back to false on SharedPerferences.
Any insights about this solution?

Transitioning from Using Jar to Dependency for Ion

I originally had ion-1.3.8.jar in my libs directory in Android Studio, with compile files('libs/ion-1.3.8.jar') in my build.gradle file. I also had (and still have) androidasync-1.3.8.jar in my libs folder and an entry for it in build.gradle.
I want to get rid of the ion jar and instead use a dependency, but when I delete the jar and put compile 'com.koushikdutta.ion:ion:2.+ in my build.gradle file, I get an error ("cannot resolve method get(String...))" on the following line of code in one of my classes: result.getHeaders().get("USER-TOKEN");.
I'm guessing that line of code probably wasn't what it should have been all along, but it did work with Ion 1.3.8. I can't figure out what I should change it to, and though I can probably figure it out with some trial and error, I would like to hear from the community or Koush about this.
Also, Android Studio is warning me that "Avoid using + in version numbers; can lead to unpredictable and unrepeatable builds". Any thoughts about this?
Here's my code:
Ion.with(activity)
.load(url)
.setJsonObjectBody(loginObject)
.asJsonObject()
.withResponse()
.setCallback(new FutureCallback<Response<JsonObject>>() {
#Override
public void onCompleted(Exception e, com.koushikdutta.ion.Response<JsonObject> result) {
String errorText = activity.getString(R.string.unable_to_login);
if (e != null) {
String errorMessage = e.getLocalizedMessage();
Log.e(TAG, errorMessage);
if (errorMessage.contains(activity.getString(R.string.unable_resolve_host))) {
errorText = activity.getString(R.string.no_internet);
}
}
else if (result != null) {
JsonElement reply = result.getResult().get(activity.getString(R.string.user));
if (reply != null) {
errorText = NO_ERROR;
SessionManager.setProfile(result.getResult());
String userToken = result.getHeaders().get(activity.getString(R.string.user_token));
SessionManager.createLoginSession(userToken);
if (SessionManager.isProfileComplete()) {
activity.startActivity(new Intent(activity, NavigationDrawerActivity.class));
}
else {
activity.startActivity(new Intent(activity, ProfileActivity.class));
}
}
else if (result.getResult().getAsJsonArray(activity.getString(R.string.errors)) != null) {
errorText = activity.getString(R.string.login_error);
}
}
else { // There was some other problem logging in
Log.e(TAG, "Unknown login problem");
}
requestCompleted.onRequestCompleted(errorText);
}
});
On version 2.+ of ION the API probably changed.
If you want to use the old API that works with your code, change your dependency to:
compile 'com.koushikdutta.ion:ion:1.3.8'
It will also automatically add the Android Async 1.3.8 dependency for you.
The warning saying that you should avoid the '+' is because that way, gradle will always get the newest version it finds, where some APIs can change and then break your code.
The API changed slightly in 2. One of those was changing the names of a few methods around the ResponseFuture and RawHeaders classes. In your case, getHeaders() was simply renamed to headers().
The transition from 1.x to 2.x is fairly painless, but there are some breaking changes nonetheless.
If you don't want to deal with the breaking changes, and use the latest version of 1.x in gradle, do the following:
compile 'com.koushikdutta.ion:ion:1.+
There are no breaking changes between 1.x versions. Current 1.x version is 1.4.1 I believe.

Phonegap plugin for android is not working. Why?

I cannot make an Android phonegap plugin work. Not even a single one of the examples I found nor my pathetic failures trying to create one by myself. I first tried with Tutorials like this one. They don't work for me. I always end up with a Cannot call method of undefined error.
So I tried something ready. Got this project from github. It's just a simple plugin to show a toast. I checked everything that i learned on the tutorials:
//the package name in the java
package com.phonegap.toast;
//my class extends Plugin and has a simple show toast method.
public class Tutorial extends Plugin {
#Override
public PluginResult execute(String cmd, JSONArray args, String callback) {
if(cmd.equals("toast"))
{
return showToast(args);
}
return null;
}
private PluginResult showToast(JSONArray args) {
final String message;
try {
message = args.getString(0);
ctx.runOnUiThread(new Runnable()
{
public void run() {
Toast myToast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
myToast.show();
}
});
return new PluginResult(PluginResult.Status.OK);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
}
}
the plugin is defined in res/xml/plugins.xml
plugin name="Tutorial" value="com.phonegap.toast.Tutorial"
and no, if i put it on rex/xml/config.xml it also doesn't work
Last, the method that calls the plugin:
function createToast() {
// i also tried window.Tutorial.showToast('Hello AndroidOpen'); with no success
window.plugins.Tutorial.showToast('Hello AndroidOpen');
}
And here I get the same error again.
10-22 15:39:07.770: E/Web Console(2885): Uncaught TypeError: Cannot call method 'showToast' of undefined at file:///android_asset/www/main.js:123
Any enlightened soul can explain to me what I'm doing wrong? I've been trying this for days, with many different plugins, both my own and even this ones and I can't find out what is it.
Okay, here are a few things that are probably tripping you up. First if the config.xml file exists in res/xml then it will take precedence over plugins.xml. So you will need to add your plugin line to config.xml instead.
Make sure you are including the .js file for your Toast plugin.
Third, window.plugins has been deprecated away so you may need to modify the .js if you are using PhoneGap 2.0.0 or better. Check out my blog post on the topic. The root change is that you now need to new PluginName in your JS as it is no longer put in window.plugins by default.

Categories

Resources