Last active
November 14, 2017 15:42
-
-
Save Ray33/80cfa9b87235446ea191d4107b874a87 to your computer and use it in GitHub Desktop.
Assemble requred parameters for video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getVideoUrl(View view, String clickUrl) { | |
int height = 300, width = 600; | |
String appName =""; | |
String gpUrl=""; | |
try { | |
appName = URLEncoder.encode(view.getContext().getString(R.string.app_name), "UTF-8"); | |
gpUrl = URLEncoder.encode( "http://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID, "UTF-8"); | |
} catch (UnsupportedEncodingException e) { | |
e.printStackTrace(); | |
} | |
if (view.getHeight() > 0) { | |
height = view.getHeight(); | |
width = view.getWidth(); | |
} | |
LocationManager locationManager = (LocationManager) view.getContext() | |
.getSystemService(LOCATION_SERVICE); | |
double lat = NetworkHelper.getLatitude(locationManager); | |
double longt = NetworkHelper.getLongitude(locationManager); | |
return clickUrl + "&width=" + width + "&height=" + height + "&app_name=" + appName + | |
"&app_version=" + BuildConfig.VERSION_CODE + "&app_id=" + BuildConfig.APPLICATION_ID + | |
"&gp_url=" + gpUrl + | |
"&lat=" + lat + "&long=" + longt + "&volume=1"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
//Open the article in Chrome custom tab
if (newsArticle.has_video) {
String videoUrl = VideoAdsHelper.getVideoUrl(view, newsArticle.clickUrl);
CustomTabHelper.openCustomTab(getContext(), mBuilder, getResources(), videoUrl);
} else {
CustomTabHelper.openCustomTab(getContext(), mBuilder, getResources(), newsArticle.clickUrl);
}