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.
Related
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.
I'm writing an acessibility service in Android which relies on getting the view id of the currently selected view, however on some devices (Nexus 6P 6.0.1, Samsung Galaxy S6 edge+ 5 + 6.0.1) I get no view id through and on others (HTC One M8 5.0.1) it comes through fine. Because it works fine on some devices, I'm sure there's not a problem with my code, however I've posted a minimal test case below.
Can anyone can help me get my service reporting ids across all devices?
The A11y service
public class ViewIdLoggingAccessibilityService extends AccessibilityService {
#Override
public void onAccessibilityEvent(AccessibilityEvent event) {
AccessibilityNodeInfo source = event.getSource();
if (source == null) {
Log.d("onAccessibilityEvent", "source was null for: " + event);
} else {
String viewIdResourceName = source.getViewIdResourceName();
Log.d("onAccessibilityEvent", "viewid: " + viewIdResourceName);
}
}
#Override
public void onInterrupt() {
Log.d("!# onInterrupt", "called");
}
}
The AndroidManifest.xml
<manifest package="com.example.a11yservice"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<service
android:name=".ViewIdLoggingAccessibilityService"
android:label="#string/view_id_logging_service_label"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
>
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="#xml/serviceconfig"
/>
</service>
</application>
</manifest>
serviceconfig.xml
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeViewClicked|typeViewFocused"
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagReportViewIds"
android:canRetrieveWindowContent="true"
android:notificationTimeout="100" />
It's known issue and was posted to AOSP issue tracker some time ago. You can check status of issue here: "Accessibility Issue: flagReportViewIds has no effect on real devices in Android M".
Unfortunately issue exists even on latest Android 7.0 but I found simple workaround. You can call refresh() method on AccessibilityNodeInfo object to refresh it and collect all missed data including id.
Something like that:
public void onAccessibilityEvent(AccessibilityEvent event) {
AccessibilityNodeInfo ani = event.getSource();
if (ani != null) {
ani.refresh(); // to fix issue with viewIdResName = null on Android 6+
}
}
I found that if the viewId isn't available, querying the focused element seems to work:
AccessibilityNodeInfo source = findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
viewIdResourceName = source.getViewIdResourceName();
returns the correct view id
I am using Google places API for android to let the user select cities in the world. Then I use the placeId to get an image to something similar to google maps.
Picture example
Every single time I'm getting the photos bundle successfully but it contains no images. It works just fine if I use the placeId of any restaurant or cafe or any other single spot but not for a whole city.
Here's the method I'm using to get the images.
public void loadPlaceImage(final ImageView imageView, String placeId) {
/**
* Load a bitmap from the photos API asynchronously
* by using buffers and result callbacks.
*/
Places.GeoDataApi.getPlacePhotos(mGoogleApiClient, placeId)
.setResultCallback(new ResultCallback<PlacePhotoMetadataResult>() {
#Override
public void onResult(PlacePhotoMetadataResult photos) {
if (!photos.getStatus().isSuccess()) {
Log.d(TAG, "Couldn\'t receive photos bundle successfully.");
return;
}
Log.d(TAG, "Photo bundle received successfully");
PlacePhotoMetadataBuffer photoMetadataBuffer = photos.getPhotoMetadata();
if (photoMetadataBuffer.getCount() > 0) {
// Display the first bitmap in an ImageView in the size of the view
photoMetadataBuffer.get(0)
.getScaledPhoto(mGoogleApiClient, imageView.getWidth(),
imageView.getHeight())
.setResultCallback(new ResultCallback<PlacePhotoResult>() {
#Override
public void onResult(PlacePhotoResult placePhotoResult) {
if (!placePhotoResult.getStatus().isSuccess()) {
Log.d(TAG, "Couldn\'t retrieve the photo successfully.");
return;
}
Log.d(TAG, "Successfully retrieved photo from photo bundle.");
imageView.setImageBitmap(placePhotoResult.getBitmap());
}
});
} else {
Log.d(TAG, "0 images in the buffer.");
}
photoMetadataBuffer.release();
}
});
}
I used your code in my android studio, it hadn't problem in your code.
I guess you forgot to add meta-data in Manifest.
<application
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOURKEY"/>
</application>
it is for reference to set up your "Android KEY"
https://developers.google.com/places/android-api/signup
https://console.developers.google.com/apis (this Link can set your key)
By the way, you can use:
Log.d(TAG,"result getStatus "+result.getStatus().getStatus());
to check your error message, hope it will help you
I'm trying to integrate InMobi in my app and I can show banner ads successfully but unable to add interstitial ads.
I've added this code in the activity from where I want to show ad.
InMobi.setLogLevel(InMobi.LOG_LEVEL.DEBUG);
InMobi.initialize(this, "Property-id");
final IMInterstitial interstitial = new IMInterstitial(this, "Property-id");
interstitial.setIMInterstitialListener(new IMInterstitialListener() {
#Override
public void onInterstitialFailed(IMInterstitial imInterstitial, IMErrorCode imErrorCode) {
Log.e(DEBUG_TAG, "Interstitial failed" + "... Error code = " + imErrorCode +
"... Internstial = " + imInterstitial);
}
#Override
public void onInterstitialLoaded(IMInterstitial imInterstitial) {
Log.e(DEBUG_TAG, "interstitial loaded");
if (interstitial.getState() == IMInterstitial.State.READY) {
interstitial.show();
}
}
#Override
public void onShowInterstitialScreen(IMInterstitial imInterstitial) {
}
#Override
public void onDismissInterstitialScreen(IMInterstitial imInterstitial) {
}
#Override
public void onInterstitialInteraction(IMInterstitial imInterstitial, Map<String, String> stringStringMap) {
}
#Override
public void onLeaveApplication(IMInterstitial imInterstitial) {
}
});
interstitial.loadInterstitial();
And for testing, I've added everything mentioned here in AndroidManifest.xml file. I've added all the permissions there, hardwareAccelerated=true in application tag and this:
<activity
android:name="com.inmobi.androidsdk.IMBrowserActivity"
android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<receiver
android:name="com.inmobi.commons.analytics.androidsdk.IMAdTrackerReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="com.inmobi.share.id" />
</intent-filter>
</receiver>
<service
android:name="com.inmobi.commons.internal.ActivityRecognitionManager"
android:enabled="true" />
But I keep getting this error "The ad request was successful, but no ad was returned" and after a small time gap, it gives "Ad network failed to retrieve ad".
For banner ads it worked successfully though. I tried it again but it's not working now. Is there something wrong with inmobi diagnostics as mentioned here (Sohan says this in his comments).
I'm from the InMobi team. Are you replacing the "Property-Id" in your code with your actual property id? I'm unsure if the code you provided above is your actual code or for illustrative purposes only...
I am using AndroidIbeacon library released by radiusnetworks and I am able to run their demo app successfully. But when I add that to my application onIBeaconServiceConnect() method is not called.
Below my code,
public class Sample extends Activity implements IBeaconConsumer {
protected static final String TAG = "Sample";
private IBeaconManager iBeaconManager = IBeaconManager
.getInstanceForApplication(this);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
iBeaconManager.bind(this);
}
#Override
protected void onDestroy() {
super.onDestroy();
iBeaconManager.unBind(this);
}
#Override
public void onIBeaconServiceConnect() {
iBeaconManager.setMonitorNotifier(new MonitorNotifier() {
#Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw an iBeacon for the firt time!");
}
#Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an iBeacon");
}
#Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG,
"I have just switched from seeing/not seeing iBeacons: "
+ state);
}
});
try {
iBeaconManager.startMonitoringBeaconsInRegion(new Region(
"myMonitoringUniqueId", null, null, null));
} catch (RemoteException e) {
}
}
}
Kindly help me to solve this issue. thanks
If manifest merging does not work, try this (worked for me):
Add the following service declarations to your AnroidManifest.xml, replacing {my app's package name} with the fully qualified package name of your Android application.
<service android:enabled="true"
android:exported="true"
android:isolatedProcess="false"
android:label="iBeacon"
android:name="com.radiusnetworks.ibeacon.service.IBeaconService">
</service>
<service android:enabled="true"
android:name="com.radiusnetworks.ibeacon.IBeaconIntentProcessor">
<meta-data android:name="background" android:value="true" />
<intent-filter
android:priority="1" >
<action android:name="{my app's package name}.DID_RANGING" />
<action android:name="{my app's package name}.DID_MONITORING" />
</intent-filter>
</service>
The most common cause of this issue is that the proper entries to start the library's service are not in the project AndroudManifest.xml file. Your new project must pull in these entries from the library's manifest using a feature called manifest merging.
Make sure you have followed the setup instructions here. If using Eclipse, verify your project.properties has manifestmerger.enabled=true.
adding
manifestmerger.enabled=true
in project.properties worked for me!
Source