Android force update - android

I am getting crash in one of my projects. This issue is in my force update code.
> Caused by java.lang.NullPointerException: Attempt to invoke virtual
> method 'java.lang.String org.jsoup.nodes.Element.ownText()' on a null
> object reference
> at com.****.android.****.activities.ForceUpdate.doInBackground(ForceUpdate.java:42)
> at com.****.android.****.activities.ForceUpdate.doInBackground(ForceUpdate.java:23)
> at android.os.AsyncTask$2.call(AsyncTask.java:295)
> at java.util.concurrent.FutureTask.run(FutureTask.java:237)
> at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
> at java.lang.Thread.run(Thread.java:818)
my code is something like this
public class ForceUpdate extends AsyncTask<String,String,JSONObject>
{
private String latestVersion;
private String currentVersion;
private Context context;
public ForceUpdate(String currentVersion, Context context){
this.currentVersion = currentVersion;
this.context = context;
}
#Override
protected JSONObject doInBackground(String... params) {
try {
latestVersion = Jsoup.connect("https://play.google.com/store/apps/details?id="+context.getPackageName()+"&hl=en")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select("div[itemprop=softwareVersion]")
.first()
.ownText();
} catch (IOException e) {
e.printStackTrace();
}
return new JSONObject();
}
#Override
protected void onPostExecute(JSONObject jsonObject) {
if(latestVersion!=null){
if(!currentVersion.equalsIgnoreCase(latestVersion)){
// Toast.makeText(context,"update is available.",Toast.LENGTH_LONG).show();
if(!(context instanceof LoginActivity)) {
if(!((Activity)context).isFinishing()){
showForceUpdateDialog();
}
}
}
}
super.onPostExecute(jsonObject);
}
public void showForceUpdateDialog(){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(context,
R.style.Theme_AppCompat_Dialog));
alertDialogBuilder.setTitle(context.getString(R.string.youAreNotUpdatedTitle));
alertDialogBuilder.setMessage(context.getString(R.string.youAreNotUpdatedMessage) + " " + latestVersion + context.getString(R.string.youAreNotUpdatedMessage1));
alertDialogBuilder.setCancelable(false);
alertDialogBuilder.setPositiveButton(R.string.updates, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
dialog.dismiss();
}
});
alertDialogBuilder.show();
}}

We are also using Jsoup to get latest app version. For us it works fine. Below is my code -
#Override
protected String doInBackground(Void... voids) {
try {
latestVersion = Jsoup.connect(context.getString(R.string.play_store_url)
+ BuildConfig.APPLICATION_ID)
.timeout(TIMEOUT)
.referrer(context.getString(R.string.google))
.get()
.select(context.getString(R.string.css_parser))
.first()
.ownText();
} catch (Exception e) {
return newVersion;
}
}
Only difference is, userAgent. Try removing it.

Related

Unable to Get latest version of play store build due to updated design of Play store

Following code used:
public class ForceUpdateAsync extends AsyncTask<String, String,
JSONObject> {
VersionListener mWsCallerVersionListener;
private String latestVersion;
private String currentVersion;
private Context context;
public ForceUpdateAsync(String currentVersion, Context context, VersionListener callback) {
this.currentVersion = currentVersion;
this.context = context;
mWsCallerVersionListener = callback;
}
#Override
protected JSONObject doInBackground(String... params) {
try {
latestVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" +
context.getPackageName() + "&hl=en")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select("div.hAyfc:nth-child(4) > span:nth-child(2) > div:nth-child(1) > span:nth-child(1)")
.first()
.ownText();
Log.e("latestversion", "---" + latestVersion);
} catch (Exception e) {
e.printStackTrace();
mWsCallerVersionListener.onGetResponse(false);
}
return new JSONObject();
}
#Override
protected void onPostExecute(JSONObject jsonObject) {
if (latestVersion != null) {
if (Float.parseFloat(currentVersion)<Float.parseFloat(latestVersion)) {
mWsCallerVersionListener.onGetResponse(true);
} else {
mWsCallerVersionListener.onGetResponse(false);
}
} else {
mWsCallerVersionListener.onGetResponse(false);
}
super.onPostExecute(jsonObject);
}
}
Getting following exception:
Attempt to invoke virtual method 'java.lang.String org.jsoup.nodes.Element.ownText()' on a null object reference
my assumption is that issue occurred due to updated html of play store. how I can get latest version of Play-store build?

Android Asyntask API deprecated

Been looking on the internet how to check the current app version of the application and the version available on Play Store. But it was using Asynctask that was deprecated already and Ive been looking alternative way aside from Asynctask been searching on the internet but I couldnt figure out how to do it correctly. Please check the code below:
private class GetLatestVersion extends AsyncTask<String, String, String> {
private String latestVersion;
private ProgressDialog progressDialog;
private boolean manualCheck;
GetLatestVersion(boolean manualCheck) {
this.manualCheck = manualCheck;
}
String currentVersion = getCurrentVersion();
//If the versions are not the same
if(!currentVersion.equals(latestVersion)&&latestVersion!=null){
final Dialog dialog = new Dialog(activity);
dialog.setContentView(R.layout.custom_warning_dialog);
dialog.setCancelable(false);
Button tryAgain = dialog.findViewById(R.id.bt_positive);
Button settings = dialog.findViewById(R.id.bt_negative);
tryAgain.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+activity.getPackageName())));
dialog.dismiss();
}
});
settings.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
activity.finish();
}
});
dialog.show();
}else {
if (manualCheck) {
Toast.makeText(activity, "No Update Available", Toast.LENGTH_SHORT).show();
}
}
}
#Override
protected String doInBackground(String... params) {
try {
//It retrieves the latest version by scraping the content of current version from play store at runtime
latestVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + activity.getPackageName() + "&hl=en")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select(".hAyfc .htlgb")
.get(7)
.ownText();
return latestVersion;
} catch (Exception e) {
return latestVersion;
}
}
}
Here's how you can basically convert asyncTask to coroutine on kotlin
private suspend fun GetLatestVersion(String,String,String) {
withContext(Dispatcher.Default)
{
// you just have to refactor all your code inside doInBaakground inside this withContext
}
//then if you want to update the UI
withContext(Dispatchers.Main)
{
//return code for your task
}
}
See this link . For further information.
Thanks Ginxx, but I used executer instead of coroutine since I am only a beginner but it might help others who the same as me.
Check my update codes below:
public void CheckLatestAppVersionFromPlayStore() {
final String[] latestAppVersionFromPlayStore = new String[1];
ExecutorService executor = Executors.newSingleThreadExecutor();
final Handler handler = new Handler(Looper.getMainLooper());
executor.execute(new Runnable() {
#Override
public void run() {
try {
//It retrieves the latest version by scraping the content of current version from play store at runtime
latestAppVersionFromPlayStore[0] = Jsoup.connect("https://play.google.com/store/apps/details?id=" + activityWeakReference.get().getPackageName() + "&hl=it")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select(".hAyfc .htlgb")
.get(7)
.ownText();
} catch (Exception e) {
e.printStackTrace();
}
handler.post(new Runnable() {
#Override
public void run() {
final String installedAppVersion = currentVersionName;
//If the versions are not the same
if (!installedAppVersion.equals(latestAppVersionFromPlayStore[0]))
if (latestAppVersionFromPlayStore[0] != null) {
final Dialog dialog = new Dialog(activityWeakReference.get());
dialog.setContentView(R.layout.custom_warning_dialog);
dialog.setCancelable(false);
Button tryAgain = dialog.findViewById(R.id.bt_positive);
Button settings = dialog.findViewById(R.id.bt_negative);
tryAgain.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
activityWeakReference.get().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + activityWeakReference.get().getPackageName())));
}
});
settings.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
activityWeakReference.get().finish();
}
});
// to avoid the bad token exception
if ((activityWeakReference.get() != null) && (!activityWeakReference.get().isFinishing()) && (!activityWeakReference.get().isDestroyed()))
dialog.show();
}
}
});
}
});
}
For further information please click this link.

Progress Bar is not showing with android picasso callbacks

I am using Picasso library for image caching in my app and while these images are loading I want to show a progressbar. I have added a callback for picasso but the progressar isnt showing. Here is my code
public class ShowProduct extends AsyncTask<String,String,ArrayList> {
#SuppressLint("StaticFieldLeak")
private static Context context;
private int width,height;
private JSONObject parsed;
static ArrayList<Data> returno=new ArrayList<>();
private String title,name,id,desc,regular_price,sale_price,code,size_guide_img,fabric,disclaimer,ref_id,ref_type;
static String[] image_info,image_gallery,color_array,size_array;
ShowProduct(Context ctx) {context = ctx;}
#Override
protected ArrayList doInBackground(String... strings) {
String url = strings[0];
getProduct(url);
return returno;
}
private void getProduct(String url) {
JsonObjectRequest mJsonArrayRequest = new JsonObjectRequest(Request.Method.GET,url,null, new Response.Listener<JSONObject>() {
public void onResponse(JSONObject response) {
Log.d("response", response.toString());
parsed = response;
try {
returno = parseJson(parsed);
} catch (ParseException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
NetworkResponse errorResponse = error.networkResponse;
if (errorResponse != null && errorResponse.data != null) {
String statusCode = String.valueOf(errorResponse.statusCode);
Log.d("l", "Status code is " + statusCode);
String fullMessage = new String(errorResponse.data);
Log.w("k", "Error message is " + fullMessage);
}
}
});
RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(mJsonArrayRequest);
}
private ArrayList<Data> parseJson(JSONObject jsonMessage) throws ParseException, JSONException {
if(context.getResources().getConfiguration().orientation==1){
width= getScreenWidth(context); height=getScreenHeight(context)/2-50;
}
else if(context.getResources().getConfiguration().orientation==2) {
width = getScreenWidth(context);
height = getScreenHeight(context) - 200;
}
JSONObject product;
JSONObject attributes;
JSONArray image_array;
JSONArray gallery_array;
JSONArray pa_color_array;
JSONArray pa_size_array;
JSONArray featured_products;
JSONObject similar_products;
ArrayList<Data> images=new ArrayList<>();
ArrayList<Data> similar=new ArrayList<>();
DatabaseOperations DB = new DatabaseOperations(context);
if (jsonMessage != null) {
try {
//Products
product = jsonMessage.getJSONObject("product");
if(product!=null){
id=product.getString("id");
name=product.getString("name");
name=name.replace("&","&");
desc=product.getString("desc");
desc=desc.replace("&","&");
image_array=product.getJSONArray("image_url");
image_info=new String[image_array.length()];
for(int b=0; b<image_array.length();b++) {
image_info[b] = image_array.get(b).toString();
}
gallery_array=product.getJSONArray("gallery");
image_gallery=new String[gallery_array.length()];
for(int b=0; b<gallery_array.length();b++) {
image_gallery[b] = gallery_array.get(b).toString();
}
regular_price=product.getString("regular_price");
sale_price=product.getString("sale_price");
code=product.getString("code");
size_guide_img=product.getString("size_guide_img");
fabric=product.getString("fabric");
disclaimer=product.getString("disclaimer");
attributes = product.getJSONObject("attributes");
pa_color_array=attributes.getJSONArray("pa_color");
color_array=new String[pa_color_array.length()];
for(int b=0; b<pa_color_array.length();b++) {
color_array[b] = pa_color_array.get(b).toString();
}
pa_size_array=attributes.getJSONArray("pa_size");
size_array=new String[pa_size_array.length()];
for(int b=0; b<pa_size_array.length();b++) {
size_array[b] = pa_size_array.get(b).toString().toUpperCase();
}
DB.deletebeforeSaving("Products",id);
DB.put_ProductActivity_Data(DB,"Products",id,name,desc,image_info[0], Arrays.toString(image_gallery),regular_price,sale_price,code,size_guide_img,fabric,disclaimer,Arrays.toString(color_array),Arrays.toString(size_array));
ProductActivity.prod_name.setText(name);
Picasso.with(context)
.load(image_info[0])
//.placeholder(R.drawable.loading)
.error(R.mipmap.ic_launcher)
.resize(width,height)
.centerInside()
.onlyScaleDown()
.into(ProductActivity.prod_img, new Callback() {
#Override
public void onSuccess() {
ProductActivity.prod_img.setVisibility(View.VISIBLE);
ProductActivity.progressBar.setVisibility(View.GONE);
}
#Override
public void onError() {
}
})
;
ProductActivity.prod_img.setContentDescription(image_info[0]);
for (int a=0; a<image_gallery.length;a++){
images.add(new Data(image_gallery[a]));
}
recycleSetHorizonatal(images,context,ProductActivity.horizontal_recycle,R.layout.product_images_scrollview,1);
if (sale_price.equals("null")){
ProductActivity.sale_price.setText(sale_price);
ProductActivity.prod_price.setText(regular_price);
}
else {
ProductActivity.prod_price.setText(regular_price);
ProductActivity.prod_price.setPaintFlags(ProductActivity.prod_price.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
ProductActivity.sale_price.setVisibility(View.VISIBLE);
ProductActivity.sale_price.setText(sale_price);
}
ProductActivity.prod_desc.setText(desc);
ProductActivity.prod_code.setText(code);
ProductActivity.prod_add_info.setText(fabric);
ProductActivity.prod_col_name.setText(color_array[0]);
ProductActivity.spiner.setPrompt("Select Size");
ArrayAdapter<String> size= new ArrayAdapter<String>(context,android.R.layout.simple_spinner_item, size_array);
size.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ProductActivity.spiner.setAdapter(size);
}
//Featured Products
featured_products = jsonMessage.getJSONArray("featured_products");
if(featured_products!=null){
for (int i=0; i<featured_products.length();i++){
similar_products=featured_products.getJSONObject(i);
if(similar_products!=null){
title=similar_products.getString("title");
title=title.replace("&","&");
image_array=similar_products.getJSONArray("image");
image_info=new String[image_array.length()];
for(int b=0; b<image_array.length();b++) {
image_info[b] = image_array.get(b).toString();
}
regular_price=similar_products.getString("regular_price");
int reg_price=Integer.valueOf(regular_price);
sale_price=similar_products.getString("sale_price");
ref_id=similar_products.getString("ref_id");
ref_type=similar_products.getString("ref_type");
DB.deletebeforeSaving("Similar_Products",ref_id);
DB.put_Similar_reference(DB,"Reference",ref_id,id);
DB.put_Similar_products
(DB,"Similar_Products",title,reg_price
,sale_price,image_info[0],ref_id,ref_type);
similar.add(new
Data(ref_id,image_info[0],title,regular_price
,sale_price,ref_type));
}
}
recycleSetHorizonatal(similar,context,ProductActivity.horizontal_recycler_view_feature,R.layout.products,4);
ProductActivity.swipe.setRefreshing(false);
}
DB.close();
} catch (final JSONException e) {
Log.e("parse error", "Json parsing error: " + e.getMessage());
}
}
return null;
}
static void recycleSetHorizonatal(ArrayList<Data> data_to_be_shown, Context context,RecyclerView view, int layout,int values) {
ProductActivity.HorizontalAdapter horizontalAdapter = new ProductActivity.HorizontalAdapter(data_to_be_shown, context,layout, values);
LinearLayoutManager horizontalLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
view.setLayoutManager(horizontalLayoutManager);
view.setAdapter(horizontalAdapter);
horizontalAdapter.notifyDataSetChanged();
}
}
XML is here
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/logo_img">
<TextView
android:id="#+id/product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="24sp"
android:layout_marginTop="20dp"
android:textColor="#color/black"
android:text="Product name"
android:gravity="center"
/>
<ImageView
android:id="#+id/prod_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:layout_marginTop="10dp"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_below="#id/product_name"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBar"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:backgroundTint="#color/brumanoGolden"
android:layout_below="#id/product_name"/>
Dependencies
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
I have updated the code with full asynctask class.
Try to set the visibllity in onPreExecute, maybe there is some problem with accessing the UI thread that is not thrown.
#Override
protected void onPreExecute() {
super.onPreExecute();
ProductActivity.progressBar.setVisibility(View.VISIBLE);
}
Then when you want to make progress invisible, set it this way:
#Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
ProductActivity.progressBar.setVisibility(View.GONE);
}
try below code :
#Override
protected void onPreExecute() {
super.onPreExecute();
showProgress(getContext().getString(R.string.uploading), getContext(), false);
}
#Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
cancelProgress();
}
public static void showProgress(String message, Context context, boolean cancellable) {
if (context == null)
return;
if (checkProgressOpen())
return;
dialog = new ProgressDialog(context);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage(message == null ? "Please wait..." : (message));
dialog.setCancelable(cancellable);
try {
dialog.show();
} catch (Exception e) {
// catch exception for activity paused and dialog is going to be
// show.
}
}
public static boolean checkProgressOpen() {
if (dialog != null && dialog.isShowing())
return true;
else
return false;
}
public static void cancelProgress() {
if (checkProgressOpen()) {
try {
dialog.dismiss();
} catch (Exception e) {
}
dialog = null;
}
}

RichRelevance SDK internally giving Null Pointer Exception. How to fix it?

// method to set the richRelevance configuration
public static void initializeRichRelevance(Context context) {
final SharedPreference sharedPreference = SharedPreference.getInstance(context);
ClientConfiguration config = new ClientConfiguration(APIKEY, CLIENTKEY);
config.setApiClientSecret("");
Log.e("Member_ID",getStringValue(sharedPreference.getSharedPref("member_id")));
config.setUserId(getStringValue(sharedPreference.getSharedPref("member_id")));
config.setSessionId(UUID.randomUUID().toString());
RichRelevance.init(context, config);
// Enable all logging
RichRelevance.setLoggingLevel(RRLog.VERBOSE);
Logger.logDebug("RichRelevance", "initilization Done...");
}
// method to fetch recommended product from richRelevance
private void initRichRelevance() {
RichRelevance.setLoggingLevel(RRLog.VERBOSE);
Placement placement = new Placement(Placement.PlacementType.ITEM, "recs_2mh");
PlacementsRecommendationsBuilder placementsRecommendationsBuilder = new PlacementsRecommendationsBuilder();
placementsRecommendationsBuilder.setPlacements(placement);
placementsRecommendationsBuilder.setProductIds(idProduct);
placementsRecommendationsBuilder.setCallback(new Callback<PlacementResponseInfo>() {
#Override
public void onResult(PlacementResponseInfo placementResponseInfo) {
JSONObject jsonObject = null;
if (placementResponseInfo != null && placementResponseInfo.getPlacements() != null) {
try {
jsonObject = new JSONObject(placementResponseInfo.getRawJson().toString());
requestAPI(jsonObject);
} catch (JSONException e) {
Utils.logExceptionCrashLytics(e);
Logger.logError("JsonException", e.getMessage());
}
}
}
#Override
public void onError(com.richrelevance.Error error) {
Log.e(getClass().getSimpleName(), "Error: " + error.getMessage());
}
}).execute();
}
Fatal Exception: java.lang.NullPointerException
at com.richrelevance.internal.net.HttpUrlConnectionExecutor.getConnection(HttpUrlConnectionExecutor.java:87)
at com.richrelevance.internal.net.HttpUrlConnectionExecutor.execute(HttpUrlConnectionExecutor.java:40)
at com.richrelevance.internal.net.WebRequestManager.execute(WebRequestManager.java:172)
at com.richrelevance.internal.net.WebRequestManager$1.run(WebRequestManager.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at com.richrelevance.internal.net.WebRequestManager$2$1.run(WebRequestManager.java:219)
at java.lang.Thread.run(Thread.java:841)

Incompatible types .Required java.lang.Integer found java.lang.String

class EndpointsAsyncTask extends AsyncTask<Pair<Context, Integer>, Void, Integer> {
private static MyApi myApiService = null;
private Context context;
#Override
protected Integer doInBackground(Pair<Context, Integer>... params) {
if(myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
#Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}});
myApiService = builder.build();}
context = params[0].first;
int name = params[0].second;
try {
return myApiService.addition(name).execute().getNo1();
// return myApiService.addition(name).execute().getNo1();
} catch (IOException e){
return e.getMessage();
}
}
#Override
protected void onPostExecute(Integer result) {
Toast.makeText(context, result, Toast.LENGTH_LONG).show();
}
}
I want to send a no to google app engine from android endpoint.and want a number to be displayed on the google app engine page .But in return e.getMessage(); I found error incompatible types
protected void onPostExecute(Integer result) {
Toast.makeText(context, result, Toast.LENGTH_LONG).show();
}
(If "result" is not a resource ID)
Toast.makeText() takes String as 2nd parameter.
Try
Toast.makeText(context, "" + result, Toast.LENGTH_LONG).show();

Categories

Resources