In my onCreate I call the following function to detect the weather.
private void detectWeather() {
if( !checkLocationPermission() ) {
return;
}
Awareness.getSnapshotClient(this).getWeather()
.addOnSuccessListener(new OnSuccessListener<WeatherResponse>() {
#Override
public void onSuccess(WeatherResponse weatherResponse) {
Weather weather = weatherResponse.getWeather();
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.e("Testing", "Could not get weather: " + e);
}
});
}
In my Manifest file I have added the following meta data and permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<meta-data
android:name="com.google.android.awareness.API_KEY"
android:value="MYKEY"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="MYKEY"/>
And in my Gradle file I've added the following dependencies.
compile 'com.google.android.gms:play-services:+'
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-location:+'
compile 'com.google.android.gms:play-services-awareness:+'
The app launches fine and gets to the awareness API, however it throws the following error in the log: com.google.android.gms.common.api.ApiException: 15. I can't really find the explanation for this error in the documentation nor on Google/Stackoverflow. Am I missing something obvious?
For future readers, weather and place is now deprecated in the Google Awareness API.
An alternative is the NumberEight SDK, which can do a lot more than Awareness (although no regioning is available at the time of writing).
It performs a wide variety of context recognition tasks on both iOS and Android including:
Real-time physical activity detection
Current place categories
Motion detection
Reachability
Local weather
It can also record user context for reports and analysis via the online portal.
To quickly receive weather updates in Java, you would write:
NumberEight ne = new NumberEight();
ne.onWeatherUpdated(
new NumberEight.SubscriptionCallback<NEWeather>() {
#Override
public void onUpdated(#NonNull Glimpse<NEWeather> glimpse) {
Log.d("CurrentWeather", glimpse.getMostProbable().toString());
}
});
Here are some iOS and Android example projects.
Disclosure: I'm one of the developers.
Related
i want to use Meta (Facebook) Audience Network bidding inside my app with Google Admob , i have done all that was written in documentation , but the problem is when i test the bidding with AdMob's test suite i see this error ..
See Image here
these are my dependencies
implementation 'com.google.android.gms:play-services-ads:21.3.0'
implementation 'com.facebook.android:audience-network-sdk:6.12.0'
implementation 'com.google.ads.mediation:facebook:6.12.0.0'
and this is in Main Activity
#Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
Map<String, AdapterStatus> statusMap = initializationStatus.getAdapterStatusMap();
for (String adapterClass : statusMap.keySet()) {
AdapterStatus status = statusMap.get(adapterClass);
Log.d("MyApp", String.format(
"Adapter name: %s, Description: %s, Latency: %d",
adapterClass, status.getDescription(), status.getLatency()));
}
MediationTestSuite.launch(MainActivity.this);
}
});
can you please tell me where am i wrong ?
i have tried to changing version code of both facebook and admob's sdk, but not works
I've implemented iOS and Android SDK, now I'm testing my app configuration in test environment. While with iOS everything seems working fine, I've noticed that with Android, the install event is correctly attributed to my quick link, any other events I'm sending (even thos I can correctly see them in the liveview) are not attributed to the quick link used to open the app.
Here my dependencies:
com.android.tools.build:gradle:3.1.1
com.google.gms:google-services:4.2.0
io.fabric.tools:gradle:1.31.0
com.android.support:appcompat-v7:28.0.0
Here the main lines of code:
#Override
protected void handleOnStart() {
super.handleOnStart();
Branch.enableDebugMode();
// Branch object initialization
Branch.getAutoInstance(this.getActivity().getApplication());
branchInstance = Branch.getInstance();
branchInstance.disableTracking(trackingDisabled);
branchInstance.initSession(new Branch.BranchReferralInitListener() {
#Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error != null) {
log("onInitFinished - " + error.getMessage());
} else {
log("onInitFinished invoked with " + referringParams.toString());
testEvent();
// Retrieve deeplink keys from 'referringParams' and evaluate the values to determine where to route the user
// Check '+clicked_branch_link' before deciding whether to use your Branch routing logic
}
}
}, getActivity().getIntent().getData(), getActivity());
}
#Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
private void testEvent() {
BranchEvent event = new BranchEvent(BRANCH_STANDARD_EVENT.VIEW_ITEM);
event.logEvent(this.getActivity());
}
And my AndroidManifest.xml looks like this:
<application android:launchMode="singleTask" .....>
<meta-data android:name="io.branch.sdk.BranchKey" android:value="#string/branchio_key_live" />
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="#string/branchio_key_test" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="#bool/branchio_test_mode" />
<receiver android:enabled="#bool/branchio_track_referral_active" android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>
It looks like your code is slightly different than what we recommend in our Android Docs, so I would recommend you conform your code as closely as possible to our code snippets as possible. For example, we recommend initializing in the onStart() method whereas you are doing yours in handleOnStart(). Here are the Android docs: https://docs.branch.io/apps/android/
If you do this and are still having difficulties, please send an email to support#branch.io and provide your App ID which is found in your Account Settings on your dashboard so we can investigate this further.
I'm writing an Android application with lots of dependencies and I needed to enable multidex because it exceeds the limit (65536k methods). I followed this guide and able to compile and run the application on my test device. The problem is I'm getting a nullpointerexception in Robospice RequestListener
for every api call that I make. I'm sure that the api is responding. It seems that the app fails to map the response to my pojo class.
Note: It's running fine before I enabled the multidex.
here is the request listener
private class MyRequestListener implements RequestListener<PojoClass> {
#Override
public void onRequestFailure(SpiceException e) {
}
#Override
public void onRequestSuccess(PojoClass pojoClass) {
// pojoClass <---- this is null
}
}
here are my dependencies for rest and mapping
'org.springframework.android:spring-android-rest-template:2.0.0.M1'
'com.octo.android.robospice:robospice-spring-android:1.4.14'
'org.codehaus.jackson:jackson-core-asl:1.9.13'
'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
Any suggestions
Hi can anyone teach me how to use zbar/zxing for qr code reader? I have tried many of the sample codes online but none seems to work. Btw im using android studio.
I used zxing-android-embedded. Handles the zxing-core for you, automatically opens the camera on a separate thread, and even has docs/examples for custom usage. Also, the authors commit often (every ~2 weeks) and respond fast to issues. It scans QR's and Barcodes out of the box.
Add the permissions for the Camera in your AndroidManifest.xml:
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Add this to your build.gradle (app):
repositories {
jcenter()
}
dependencies {
compile 'com.journeyapps:zxing-android-embedded:3.0.2#aar'
compile 'com.google.zxing:core:3.2.0'
}
Create a callback in your Activity:
private BarcodeCallback callback = new BarcodeCallback() {
#Override
public void barcodeResult(BarcodeResult result) {
// Do something with the scanned QR code.
// result.getText() returns decoded QR code.
fooBar(result.getText());
}
#Override
public void possibleResultPoints(List<ResultPoint> resultPoints) {
}
};
onCreate()
mBarcodeView = (BarcodeView) findViewById(R.id.barcode_view);
// Choose only one!!!
mBarcodeView.decodeSingle(callback);
// Or
mBarcodeView.decodeContinuous(callback);
onResume()
mBarcodeView.resume();
onPause()
mBarcodeView.pause();
In your Activity's XML layout, add the BarcodeView
<com.journeyapps.barcodescanner.BarcodeView
android:id="#+id/barcode_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</com.journeyapps.barcodescanner.BarcodeView>
Hope this helps!
I want to add statistic in my android application.
Read article http://code.google.com/intl/ru/apis/analytics/docs/mobile/android.html#startingTheTracker and done below
1 added library libGoogleAnalytics.jar in my application
2 added in manifest
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
3 changed source code
private GoogleAnalyticsTracker tracker;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tracker = GoogleAnalyticsTracker.getInstance();
// Start the tracker in manual dispatch mode...
tracker.startNewSession(GOOGLE_ANALYTICS, this);
tracker.trackPageView("/MainListView");
...
protected void onDestroy() {
super.onDestroy();
tracker.stopSession();
}
4 I created "fake" site for application (https://sites.google.com/site/balancetransportcardkazan/ :) )
5 registered site in https://www.google.com/analytics/,
constant GOOGLE_ANALYTICS is for this site.
statistic is empty, What I forgot to do?
You have to dispatch the changes to the server. Here is an excerpt from my wrapper class around GoogleTracker to make it easier for me.
public void trackPageView(String page) {
tracker.trackPageView( packageName + "/" + getVersionCode() + "/" + page );
tracker.dispatch();
}
public void trackEvent(String action, String label, int count) {
tracker.trackEvent( packageName, action, label, count );
tracker.dispatch();
}
public void trackEvent(String action) {
tracker.trackEvent(packageName, action, null, 0 );
tracker.dispatch();
}
As mentioned by chubbard You need to dispatch the events to get it tracked. check your logs whether requests are sent to GA server. As i have seen it usually takes around 4-5 hours for statistics to get updated. While viewing the report ensure the report date is current date. By default the report will be shown for yesterday.
I think for getting statics of your android app, you should implement google analytics code into all your classes/functions of the your app.
I think below link can help you for How to implement Google Analytics for android app -
http://www.tatvic.com/blog/android-application-tracking-through-google-analytics/