Setting Pending Intent to Builder in Onesignal NotificationExtenderService doesn't get Detected - android

I want to call Webview_activity on Notification Tap when app is killed , so in NotificationExtender Service ive attached Pending intent with the builder using setContentIntent() method, but nothing happens when notification is tapped.
Webview_activity is successfully called when application is alive, as that is handled by notificationOpened(), but when app is killed, onNotificationProcessing() is called but on Notification tap Webview_activity is not called.
I also read that Onesignal do not detect the setContentIntent() when attached to the builder here is the link :
https://github.com/OneSignal/OneSignal-Android-SDK/issues/511
is there a way around? how can i call my activity on notification tap using onNotificationProcessing() of NotificationExtender Service when app is killed.
#Override
protected boolean onNotificationProcessing(final OSNotificationReceivedResult notification) {
Log.d(TAG, "onNotificationProcessing");
final NotificationCompat.Builder[] newbuilder = new NotificationCompat.Builder[1];
OverrideSettings overrideSettings = new OverrideSettings();
overrideSettings.extender = new NotificationCompat.Extender() {
#Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
// Sets the background notification color to Green on Android 5.0+ devices.
newbuilder[0] = builder;
Intent intent = new Intent();
try {
JSONObject data = notification.payload.additionalData;
if (data != null) {
String url = data.optString("url", null);
if (url != null) {
if (getApplicationContext() != null) {
Log.d(TAG, "context is not null");
intent = new Intent(getApplicationContext(), Webview_activity.class);
intent.putExtra("url", url);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
} else {
Log.d(TAG, "context is null");
}
}
}
**PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
newbuilder[0] = builder.setContentIntent(pendIntent);**
} catch (Exception e) {
e.printStackTrace();
}
return newbuilder[0];
}
};
overrideSettings.extender.extend(newbuilder[0]);
OSNotificationDisplayedResult displayedResult = displayNotification(overrideSettings);
Log.d("OneSignalExample", "Notification displayed with id: " + displayedResult.androidNotificationId);
return true;
}
#Override
public void notificationOpened(OSNotificationOpenResult result)
{
Log.d(TAG,"notificationOpened");
try {
JSONObject data = result.notification.payload.additionalData;
if (data != null) {
String url = data.optString("url", null);
if (url != null) {
if (context!=null)
{
Log.d(TAG,"context is not null");
Intent intent = new Intent(context, Webview_activity.class);
intent.putExtra("url", url);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}else {
Log.d(TAG,"context is null");
}
}
}
}catch (Exception e)
{
e.printStackTrace();
}
}

Related

TileService not working, tile becomes unresponsive

I've made a tileService which triggers a foreground service when clicked. I have taken the battery optimisation permission from settings and set it on don't optimise. However after 3 days the tile becomes unresponsive.
public class QSIntentService
extends TileService {
String TAG = getClass().getSimpleName();
Context context;
boolean isTileActive;
#Override
public void onStartListening() {
super.onStartListening();
Log.e(TAG, "-----onStartListening Tile--");
if (isServiceRunning(getApplicationContext())) {
isTileActive = true;
updateTile();
} else {
isTileActive = false;
updateTile();
}
}
#Override
public void onClick() {
context = getApplicationContext();
Log.e(TAG, "-----onClick --- ");
Tile tile = getQsTile();
isTileActive = (tile.getState() == Tile.STATE_ACTIVE);
Intent serviceIntent = new Intent(context,
ForegroundService.class);
if (isServiceRunning(context)) {
isTileActive = false;
Utils.setBooleanFromPref(context,
context.getString(R.string.widgetStop), true);
if (ShareIBeaconInfo.INSTANCE.getForegroundService() != null) {
ForegroundService foregroundService =
ShareIBeaconInfo.INSTANCE.getForegroundService();
if (foregroundService.scanDevice != null) {
foregroundService.stopForegroundService();
}
}
context.stopService(serviceIntent);
} else {
isTileActive = true;
Utils.setBooleanFromPref(context,
context.getString(R.string.widgetStop), false);
Log.e(TAG, "service is not running");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent service = new Intent(context,
ForegroundService.class);
ContextCompat.startForegroundService(context, service);
} else {
Intent service = new Intent(context, ForegroundService.class);
context.startService(service);
}
}
updateTile();
}
private void updateTile() {
Tile tile = super.getQsTile();
int activeState = isTileActive ?
Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
tile.setState(activeState);
tile.updateTile();
}
private boolean isServiceRunning(Context context) {
try {
final ActivityManager manager;
manager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager
.getRunningServices(Integer.MAX_VALUE)) {
if ("com.foregroundscan.service.ForegroundService"
.equalsIgnoreCase(service.service.getClassName())) {
return true;
}
}
} catch (NullPointerException ex) {
} catch (Exception e) {
}
return false;
}
}
My test device is OnePlus 6T running over android 9. Also is there a way to push a dialogue if the tile is unresponsive? So that I can restart the service?
I received a log when I click on a tile when it is unresponsive
2-08 16:34:56.710 1831-2154/? E/MdmLogger: Cannot get tag from tileTag
: Tile.CustomTile

How to get context in service outside of onStartCommand() method?

When I use Intent outside of onStartCommand() of service, to show notification on a specific event, it shows getApplicationContext on the null object reference.
Service only allow to use getApplcationContext/this/context inside the onStartCommand() method.
How can I use it outside of onStartCommand() method?
Below is my Service. Can someone help me out with this?
public class ForegroundService extends Service {
#Nullable
private static TransferUtility transferUtility;
private static ArrayList<HashMap<String, Object>> transferRecordMaps;
private static ArrayList<HashMap<String, Object>> transferRecordMaps1;
private Utils utils = new Utils();
private static final int INDEX_NOT_CHECKED = -1;
public static int totalcount, totalAssetCount;
private int checkedIndex;
private static List<TransferObserver> observers;
private static int REQUEST_CAMERA = 0, navigate = 0,counter=0,failedcounter=0;
private static final String LOG_TAG = "ForegroundService";
UploadMediaToAssetFragment uploadMediaToAssetFragment;
private int progress;
Context context;
private long currentbyte, totalbyte;
private Notification notification;
#Override
public void onCreate() {
super.onCreate();
transferUtility = Util.getTransferUtility(getApplicationContext());
checkedIndex = INDEX_NOT_CHECKED;
transferRecordMaps = new ArrayList<HashMap<String, Object>>();
transferRecordMaps1 = new ArrayList<HashMap<String, Object>>();
uploadMediaToAssetFragment = new UploadMediaToAssetFragment();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent.getAction().equals(Constants.ACTION.STARTFOREGROUND_ACTION)) {
Log.i(LOG_TAG, "Received Start Foreground Intent ");
Intent notificationIntent = new Intent(this, UploadMediaToAssetFragment.class);
notificationIntent.setAction(Constants.ACTION.MAIN_ACTION);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
Log.d(LOG_TAG,"bytes"+UploadMediaToAssetFragment.totalAssetCount+ " total"+UploadMediaToAssetFragment.totalcount);
uploadAsset();
initData();
updateList();
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
// builder.setTitle("Test dialog");
// builder.setIcon(R.drawable.icon);
// builder.setMessage("Content");
//
// AlertDialog alert = builder.create();
// alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// alert.show();
// startActivity(notificationIntent);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
Intent previousIntent = new Intent(this, ForegroundService.class);
previousIntent.setAction(Constants.ACTION.PREV_ACTION);
PendingIntent ppreviousIntent = PendingIntent.getService(this, 0,
previousIntent, 0);
Intent playIntent = new Intent(this, ForegroundService.class);
playIntent.setAction(Constants.ACTION.PLAY_ACTION);
PendingIntent pplayIntent = PendingIntent.getService(this, 0,
playIntent, 0);
Intent nextIntent = new Intent(this, ForegroundService.class);
nextIntent.setAction(Constants.ACTION.NEXT_ACTION);
PendingIntent pnextIntent = PendingIntent.getService(this, 0,
nextIntent, 0);
Bitmap icon = BitmapFactory.decodeResource(getResources(),
R.drawable.logo);
notification = new NotificationCompat.Builder(this)
.setContentTitle("Visibly")
.setTicker("asset uplaoding")
.setContentText("uploading")
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(
Bitmap.createScaledBitmap(icon, 128, 128, false))
.setContentIntent(pendingIntent)
.setOngoing(true)
.setProgress(100,progress,false)
.addAction(android.R.drawable.ic_menu_close_clear_cancel,
"cancel", ppreviousIntent).build();
startForeground(Constants.NOTIFICATION_ID.FOREGROUND_SERVICE,
notification);
// if(UploadMediaToAssetFragment.totalAssetCount>=UploadMediaToAssetFragment.totalcount)
// {
// onDestroy();
// stopForeground(true);
// stopSelf();
// }
} else if (intent.getAction().equals(Constants.ACTION.PREV_ACTION)) {
Log.i(LOG_TAG, "Clicked Previous");
} else if (intent.getAction().equals(Constants.ACTION.PLAY_ACTION)) {
Log.i(LOG_TAG, "Clicked Play");
} else if (intent.getAction().equals(Constants.ACTION.NEXT_ACTION)) {
Log.i(LOG_TAG, "Clicked Next");
} else if (intent.getAction().equals(
Constants.ACTION.STOPFOREGROUND_ACTION)) {
Log.i(LOG_TAG, "Received Stop Foreground Intent");
stopForeground(true);
stopSelf();
}
return START_STICKY;
}
#Override
public void onDestroy() {
super.onDestroy();
Log.i(LOG_TAG, "In onDestroy");
}
public IBinder onBind(Intent intent) {
return null;
}
public class ForegroundServiceBInder extends Binder {
ForegroundService getService() {
// Return this instance of LocalService so clients can call public methods
return ForegroundService.this;
}
}
public void uploadAsset()
{
Log.d("upload asset service","method called");
for(int i=0;i<AddMediaAssetActivity.galleryDTOArrayList1.size();i++)
{
Handler handler1 = new Handler();
try {
if(AddMediaAssetActivity.galleryDTOArrayList1.get(i)!=null)
{
String path;
Uri uri = Uri.fromFile(new File(AddMediaAssetActivity.galleryDTOArrayList1.get(i).getMediaName()));
path = Utility.getPath(uri, getApplicationContext());
Uri uriThumb = Uri.fromFile(new File(AddMediaAssetActivity.galleryDTOArrayList1.get(i).getThumbnail()));
String pathThum = null;
if (uriThumb != null)
pathThum = Utility.getPath(uriThumb, getApplicationContext());
path = Utility.getPath(uri, getApplicationContext());
if(GlobalVariables.isNetworkAvailable(getApplicationContext())) {
beginUpload1(pathThum, pathThum);
beginUpload(path, AddMediaAssetActivity.galleryDTOArrayList1.get(i).getDescription(), pathThum,AddMediaAssetActivity.galleryDTOArrayList1.get(i).getCreateTagPostDTOList());
}else
{
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(getApplicationContext(),android.R.style.Theme_Material_Light_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(getApplicationContext());
}
builder.setMessage(getResources().getString(R.string.network_connectivity))
.setTitle("");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
//getApplicationContext().finish();
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(true);
dialog.show();
dialog.getButton(dialog.BUTTON_POSITIVE).setTextColor(getResources().getColor(R.color.clear_blue));
}
}
}catch (Exception e)
{
}
}
}
/*
* Begins to upload the file specified by the file path.
*/
private void beginUpload(String filePath, String title, String pathThum, List<TagDTO> createTagPostDTOList)
{
Log.d("beginUpload","method called "+filePath+" title "+title+" pathnum "+pathThum+" list tagdto"+createTagPostDTOList);
if (filePath == null) {
Toast.makeText(getApplicationContext(), "Could not find the filepath of the selected file",
Toast.LENGTH_LONG).show();
return;
}
File file = new File(filePath);
TransferObserver observer = transferUtility.upload(Constants.BUCKET_NAME, Constants.FOLDERNAME_NAME+"/"+ file.getName(),
file, CannedAccessControlList.PublicRead);
File file1 = new File(pathThum);
AssetMediaDTO assetMediaDTO=new AssetMediaDTO();
if(GlobalVariables.isCampaignAsset)
{
if (GlobalVariables.campaignFeedDTO.getCampaign_category() != null && GlobalVariables.campaignFeedDTO.getCampaign_category().length() > 0 && !(GlobalVariables.campaignFeedDTO.getCampaign_category().equalsIgnoreCase("null"))) {
assetMediaDTO.setCategory_id(GlobalVariables.campaignFeedDTO.getCampaign_category());
} else {
assetMediaDTO.setCategory_id("rpPDp");
}
if (GlobalVariables.campaignFeedDTO.getCampaign_folder() != null && GlobalVariables.campaignFeedDTO.getCampaign_folder().length() > 0 && !(GlobalVariables.campaignFeedDTO.getCampaign_folder().equalsIgnoreCase("null"))) {
if(GlobalVariables.campaignFeedDTO.getCampaign_folder().equalsIgnoreCase("General"))
{
assetMediaDTO.setFolder_id("");
}else
{
assetMediaDTO.setFolder_id(GlobalVariables.campaignFeedDTO.getCampaign_folder());
}
} else
{
assetMediaDTO.setFolder_id("");
}
}else
{
if (AssetFolderActivity.folderDTO.getCategoryID() != null && AssetFolderActivity.folderDTO.getCategoryID().length() > 0 && !(AssetFolderActivity.folderDTO.getCategoryID().equalsIgnoreCase("null"))) {
assetMediaDTO.setCategory_id(AssetFolderActivity.folderDTO.getCategoryID());
} else {
assetMediaDTO.setCategory_id("rpPDp");
}
if (AssetFolderActivity.folderDTO.getFolderIdentity() != null && AssetFolderActivity.folderDTO.getFolderIdentity().length() > 0 && !(AssetFolderActivity.folderDTO.getFolderIdentity().equalsIgnoreCase("null"))) {
if(AssetFolderActivity.folderDTO.getFoldername()!=null&&AssetFolderActivity.folderDTO.getFoldername().equalsIgnoreCase("general"))
{
assetMediaDTO.setFolder_id("");
}else {
assetMediaDTO.setFolder_id(AssetFolderActivity.folderDTO.getFolderIdentity());
}
} else {
assetMediaDTO.setFolder_id("");
}
}
assetMediaDTO.setMedia_url(GlobalVariables.s3Path+Constants.FOLDERNAME_NAME+"/"+file.getName());
assetMediaDTO.setThumbnail_url(GlobalVariables.s3Path+Constants.FOLDERNAME_NAME+"/"+file1.getName());
try {
assetMediaDTO.setMediaSize(""+file.length());
}catch (Exception e)
{
}
assetMediaDTO.setDetail(title);
String result = file.getName().substring(0, file.getName().lastIndexOf("."));
assetMediaDTO.setTitle(result);
assetMediaDTO.setTagDTOList(createTagPostDTOList);
GlobalVariables.assetMediaDTOList.add(assetMediaDTO);
}
/*
* Begins to upload the file specified by the file path.
*/
private void beginUpload1(String filePath, String pathThum) {
Log.d("beginUpload1","method called");
if (filePath == null) {
Toast.makeText(getApplicationContext(), "Could not find the filepath of the selected file",
Toast.LENGTH_LONG).show();
return;
}
File file = new File(filePath);
TransferObserver observer = transferUtility.upload(Constants.BUCKET_NAME, Constants.FOLDERNAME_NAME+"/"+ file.getName(),
file,CannedAccessControlList.PublicRead);
// temp1=file.getName();
}
//To delete assets from list
public void deleteMediaUpload(final int position)
{
final int position1=position+1;
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(GlobalVariables.mActivity, android.R.style.Theme_Material_Light_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(GlobalVariables.mActivity);
}
builder.setMessage("Do you want to delete this media?")
.setTitle("");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
dialog.dismiss();
if (position >= 0 && position1 < observers.size())
{
try {
transferUtility.deleteTransferRecord(observers.get(position).getId());
transferUtility.deleteTransferRecord(observers.get(position1).getId());
observers.remove(position1);
transferRecordMaps.remove(position1);
observers.remove(position);
transferRecordMaps.remove(position);
AddMediaAssetActivity.galleryDTOArrayList1.remove(position);
}catch (Exception e)
{
}
updateList();
try {
GlobalVariables.assetMediaDTOList.remove(position);
}catch (Exception e)
{
}
}
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.show();
dialog.getButton(dialog.BUTTON_NEGATIVE).setTextColor(GlobalVariables.mActivity.getResources().getColor(R.color.clear_blue));
dialog.getButton(dialog.BUTTON_POSITIVE).setTextColor(GlobalVariables.mActivity.getResources().getColor(R.color.clear_blue));
}
// /**
// * Gets all relevant transfers from the Transfer Service for populating the
// * UI
// */
// private void initData() {
// counter=0;
// failedcounter=0;
// navigate=0;
// transferRecordMaps.clear();
// transferRecordMaps1.clear();
// // Use TransferUtility to get all upload transfers.
// observers = transferUtility.getTransfersWithType(TransferType.UPLOAD);
// TransferListener listener = new UploadMediaToAssetFragment.UploadListener();
// for (TransferObserver observer : observers) {
//
// // For each transfer we will will create an entry in
// // transferRecordMaps which will display
// // as a single row in the UI
// HashMap<String, Object> map = new HashMap<String, Object>();
// Util.fillMap(map, observer, false);
//
// transferRecordMaps.add(map);
//
// // Sets listeners to in progress transfers
// if (TransferState.WAITING.equals(observer.getState())
// || TransferState.WAITING_FOR_NETWORK.equals(observer.getState())
// || TransferState.IN_PROGRESS.equals(observer.getState())) {
// observer.setTransferListener(listener);
// }
// }
// transferRecordMaps1.clear();
// for(int i=0;i<transferRecordMaps.size();i++)
// {
// File file = new File((String) transferRecordMaps.get(i).get("fileName"));
// if(file.getName().substring(0,2).equalsIgnoreCase("0!"))
// {
// }
// else
// {
// transferRecordMaps1.add(transferRecordMaps.get(i));
//
// }
//
// }
// assetListAdapter.notifyDataSetChanged();
// }
/*
* A TransferListener class that can listen to a upload task and be notified
* when the status changes.
*/
public class UploadListener implements TransferListener {
// Simply updates the UI list when notified.
#Override
public void onError(int id, Exception e)
{
failedcounter++;
updateList();
}
#Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
updateList();
currentbyte =bytesCurrent;
totalbyte =bytesTotal;
Log.d("onprogresschnaged","method bytes"+bytesCurrent+" bytestotoal"+bytesTotal);
}
#Override
public void onStateChanged(int id, TransferState newState)
{
if (newState.equals(TransferState.COMPLETED))
{
counter++;
updateList();
} else if (newState.equals(TransferState.FAILED))
{
failedcounter++;
updateList();
}
}
}
/*
* Updates the ListView according to the observers.
*/
/*
* Updates the ListView according to the observers.
*/
public void updateList()
{
if(transferRecordMaps!=null&&transferRecordMaps.size()>0)
{
TransferObserver observer = null;
HashMap<String, Object> map = null;
for (int i = 0; i < observers.size(); i++) {
observer = observers.get(i);
map = transferRecordMaps.get(i);
progress = (int) ((double) observer.getBytesTransferred() * 100 / observer
.getBytesTotal());
Log.d("progressuploadingData"," map"+progress);
Util.fillMap(map, observer, i == checkedIndex);
Log.d("uploadingData"," map"+map+" observer"+observer);
}
transferRecordMaps1.clear();
for (int i = 0; i < transferRecordMaps.size(); i++)
{
File file = new File((String) transferRecordMaps.get(i).get("fileName"));
if (file.getName().substring(0, 2).equalsIgnoreCase("0!")) {
} else
{
transferRecordMaps1.add(transferRecordMaps.get(i));
}
totalcount=transferRecordMaps.size();
totalAssetCount=counter+failedcounter;
Log.d("totalcount","count"+totalcount+"toatlassetcount"+totalAssetCount);
if(counter>1&&totalAssetCount>=totalcount&&GlobalVariables.assetMediaDTOList.size()>0)
{
Log.d("myservice asset","complete");
navigate=1;
Intent intent = new Intent(this, DialogeActivity.class);
context.getApplicationContext().startActivity(intent);
// Toast.makeText(this,"Your asset uploaded successfully",Toast.LENGTH_LONG).show();
// Intent notificationIntent = new Intent(this, DialogeActivity.class);
// notificationIntent.setAction(Constants.ACTION.MAIN_ACTION);
// notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
// | Intent.FLAG_ACTIVITY_CLEAR_TASK);
// startActivity(notificationIntent);
// Notification notification = new NotificationCompat.Builder(this)
// .setContentTitle("Visibly")
// .setTicker("asset uploaded")
// .setContentText("asset uploaded successfully")
// .setSmallIcon(R.drawable.ic_launcher)
// .build();
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
// builder.setTitle("Test dialog");
// builder.setIcon(R.drawable.icon);
// builder.setMessage("Content");
// builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int whichButton) {
// //Do something
// dialog.dismiss();
// });
//
// AlertDialog alert = builder.create();
// alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// alert.show();
// AlertDialog alertDialog = new AlertDialog.Builder(this)
// .setTitle("Title")
// .setMessage("Are you sure?")
// .create();
//
// alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// alertDialog.show();
// button_Done.setVisibility(View.VISIBLE);
// button_Done.setText("Done");
// button_Done.setEnabled(true);
// button_Done.setClickable(true);
}else if(failedcounter>=totalcount)
{
navigate=0;
// button_Done.setVisibility(View.VISIBLE);
// button_Done.setText("Back");
// button_Done.setEnabled(true);
// button_Done.setClickable(true);
}else
{
// button_Done.setVisibility(View.VISIBLE);
// button_Done.setText("Please wait.");
// button_Done.setEnabled(false);
// button_Done.setClickable(false);
}
}
// assetListAdapter.notifyDataSetChanged();
}else
{
// Intent intent=null;
// if( AssetFolderActivity.folderDTO!=null&&AssetFolderActivity.folderDTO.getFolderIdentity()!=null&& AssetFolderActivity.folderDTO.getFolderIdentity().length()>0&&!AssetFolderActivity.folderDTO.getFolderIdentity().equalsIgnoreCase("")) {
// intent = new Intent(activity, AssetFolderActivity.class);
// }else
// {
// intent = new Intent(activity, DashboardActivity.class);
// }
// intent.putExtra("folderDTO", AssetFolderActivity.folderDTO);
// activity.startActivity(intent);
// activity.finish();
}
}
private void initData() {
counter=0;
failedcounter=0;
navigate=0;
transferRecordMaps.clear();
transferRecordMaps1.clear();
// Use TransferUtility to get all upload transfers.
observers = transferUtility.getTransfersWithType(TransferType.UPLOAD);
TransferListener listener = new ForegroundService().new UploadListener();
for (TransferObserver observer : observers) {
// For each transfer we will will create an entry in
// transferRecordMaps which will display
// as a single row in the UI
HashMap<String, Object> map = new HashMap<String, Object>();
Util.fillMap(map, observer, false);
transferRecordMaps.add(map);
// Sets listeners to in progress transfers
if (TransferState.WAITING.equals(observer.getState())
|| TransferState.WAITING_FOR_NETWORK.equals(observer.getState())
|| TransferState.IN_PROGRESS.equals(observer.getState())) {
observer.setTransferListener(listener);
}
}
transferRecordMaps1.clear();
for(int i=0;i<transferRecordMaps.size();i++)
{
File file = new File((String) transferRecordMaps.get(i).get("fileName"));
if(file.getName().substring(0,2).equalsIgnoreCase("0!"))
{
}
else
{
transferRecordMaps1.add(transferRecordMaps.get(i));
}
}
// assetListAdapter.notifyDataSetChanged();
}
}
Service only allow to use getApplcationContext/this/context inside the onStartCommand() method
There is no such restriction. You can use it from other methods on your Service, so long as onCreate() has already been called on that Service.
So, to show a Notification from some background thread that your Service forks from onStartCommand(), for example, use this.
Service is child of Context class, that would provide you context when you need. It behaves like an activity (child of context too.)
So same like Activity, you can call this or yourService.this(in anonymus class) keyword as a context.
In updateList() you do this:
context.getApplicationContext().startActivity(intent);
context is a member variable of your Service. However, you never initialize this variable to anything. Therefore it is null, which will cause the error you describe.
Sevices has his own context. There is easy way to have an globl context.
private Context context;
#Override
public int onStartCommand(#Nullable Intent intent, int flags, int startId) {
context = this;
}
That's all. Should work, if not let search an problem in other place.
#Edit
For clarity, your problem causes this line, because your context is not assigned, and it's null.
context.getApplicationContext().startActivity(intent);

Geofencing Intent Not Firing

Hello everyone i am implementing geofencing feature in my android application to send toast notifications.The thing is when i am inside(where i am making fences) a fence that i have created then the intent is fired but when i try to fire the event again by reentering the location intent is not firing here is my code
protected override void OnHandleIntent (Intent intent)
{
Intent broadcastIntent = new Intent();
var geofencingEvent = GeofencingEvent.FromIntent (intent);
if (geofencingEvent.HasError) {
var errorMessage = GeofenceErrorMessages.GetErrorString (this, geofencingEvent.ErrorCode);
Log.Error (TAG, errorMessage);
return;
}
int geofenceTransition = geofencingEvent.GeofenceTransition;
if (geofenceTransition == Geofence.GeofenceTransitionEnter ||
geofenceTransition == Geofence.GeofenceTransitionExit) {
Toast.MakeText(this, "Service Started", ToastLength.Long).Show();
IList<IGeofence> triggeringGeofences = geofencingEvent.TriggeringGeofences;
string geofenceTransitionDetails = GetGeofenceTransitionDetails (this, geofenceTransition, triggeringGeofences);
SendNotification (geofenceTransitionDetails);
Log.Info (TAG, geofenceTransitionDetails);
} else {
// Log the error.
Log.Error (TAG, GetString (Resource.String.geofence_transition_invalid_type, new [] { new Java.Lang.Integer (geofenceTransition) }));
}
}
string GetGeofenceTransitionDetails (Context context, int geofenceTransition, IList<IGeofence> triggeringGeofences)
{
string geofenceTransitionString = GetTransitionString (geofenceTransition);
var triggeringGeofencesIdsList = new List<string> ();
foreach (IGeofence geofence in triggeringGeofences) {
triggeringGeofencesIdsList.Add (geofence.RequestId);
}
var triggeringGeofencesIdsString = string.Join (", ", triggeringGeofencesIdsList);
return geofenceTransitionString + ": " + triggeringGeofencesIdsString;
}
void SendNotification (string notificationDetails)
{
var notificationIntent = new Intent (ApplicationContext, typeof(MainActivity));
var stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create (this);
stackBuilder.AddParentStack (Java.Lang.Class.FromType (typeof(MainActivity)));
stackBuilder.AddNextIntent (notificationIntent);
var notificationPendingIntent = stackBuilder.GetPendingIntent (0, (int)PendingIntentFlags.UpdateCurrent);
var builder = new NotificationCompat.Builder (this);
builder.SetSmallIcon (Resource.Drawable.icon)
.SetLargeIcon (BitmapFactory.DecodeResource (Resources, Resource.Drawable.icon))
.SetColor (Color.Red)
.SetContentTitle (notificationDetails)
.SetContentText (GetString (Resource.String.geofence_transition_notification_text))
.SetContentIntent (notificationPendingIntent);
builder.SetAutoCancel (true);
var mNotificationManager = (NotificationManager)GetSystemService (Context.NotificationService);
mNotificationManager.Notify (0, builder.Build ());
}
string GetTransitionString (int transitionType)
{
switch (transitionType) {
case Geofence.GeofenceTransitionEnter:
return GetString (Resource.String.geofence_transition_entered);
case Geofence.GeofenceTransitionExit:
return GetString (Resource.String.geofence_transition_exited);
default:
return GetString (Resource.String.unknown_geofence_transition);
}
}
and my main activity is
{
protected const string TAG = "creating-and-monitoring-geofences";
protected GoogleApiClient mGoogleApiClient;
protected IList<IGeofence> mGeofenceList;
bool mGeofencesAdded;
PendingIntent mGeofencePendingIntent;
ISharedPreferences mSharedPreferences;
Button mAddGeofencesButton;
Button mRemoveGeofencesButton;
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView (Resource.Layout.main_activity);
mAddGeofencesButton = FindViewById<Button> (Resource.Id.add_geofences_button);
mRemoveGeofencesButton = FindViewById<Button> (Resource.Id.remove_geofences_button);
mAddGeofencesButton.Click += AddGeofencesButtonHandler;
mRemoveGeofencesButton.Click += RemoveGeofencesButtonHandler;
mGeofenceList = new List<IGeofence> ();
mGeofencePendingIntent = null;
mSharedPreferences = GetSharedPreferences (Constants.SHARED_PREFERENCES_NAME,
FileCreationMode.Private);
mGeofencesAdded = mSharedPreferences.GetBoolean (Constants.GEOFENCES_ADDED_KEY, false);
SetButtonsEnabledState ();
PopulateGeofenceList ();
BuildGoogleApiClient ();
}
protected void BuildGoogleApiClient ()
{
mGoogleApiClient = new GoogleApiClient.Builder (this)
.AddConnectionCallbacks (this)
.AddOnConnectionFailedListener (this)
.AddApi (LocationServices.API)
.Build ();
}
private IntentFilter mIntentFilter;
protected override void OnResume ()
{
base.OnResume();
mGoogleApiClient.Connect ();
}
protected override void OnStart()
{
base.OnStart();
mGoogleApiClient.Connect();
}
protected override void OnStop ()
{
base.OnStop ();
// mGoogleApiClient.Disconnect ();
}
public void OnConnected (Bundle connectionHint)
{
Log.Info (TAG, "Connected to GoogleApiClient");
}
public void OnConnectionSuspended (int cause)
{
Log.Info (TAG, "Connection suspended");
}
public void OnConnectionFailed (Android.Gms.Common.ConnectionResult result)
{
Log.Info (TAG, "Connection failed: ConnectionResult.getErrorCode() = " + result.ErrorCode);
}
GeofencingRequest GetGeofencingRequest ()
{
var builder = new GeofencingRequest.Builder ();
builder.SetInitialTrigger (GeofencingRequest.InitialTriggerEnter);
builder.AddGeofences (mGeofenceList);
return builder.Build ();
}
public async void AddGeofencesButtonHandler (object sender, EventArgs e)
{
if (!mGoogleApiClient.IsConnected) {
Toast.MakeText (this, GetString (Resource.String.not_connected), ToastLength.Short).Show ();
return;
}
try {
var status = await LocationServices.GeofencingApi.AddGeofencesAsync (mGoogleApiClient, GetGeofencingRequest (),
GetGeofencePendingIntent ());
HandleResult (status);
} catch (SecurityException securityException) {
LogSecurityException(securityException);
}
}
public async void RemoveGeofencesButtonHandler (object sender, EventArgs e)
{
if (!mGoogleApiClient.IsConnected) {
Toast.MakeText (this, GetString(Resource.String.not_connected), ToastLength.Short).Show ();
return;
}
try {
var status = await LocationServices.GeofencingApi.RemoveGeofencesAsync (mGoogleApiClient,
GetGeofencePendingIntent ());
HandleResult (status);
} catch (SecurityException securityException) {
LogSecurityException (securityException);
}
}
void LogSecurityException (SecurityException securityException)
{
Log.Error (TAG, "Invalid location permission. " +
"You need to use ACCESS_FINE_LOCATION with geofences", securityException);
}
public void HandleResult (Statuses status)
{
if (status.IsSuccess) {
mGeofencesAdded = !mGeofencesAdded;
var editor = mSharedPreferences.Edit ();
editor.PutBoolean (Constants.GEOFENCES_ADDED_KEY, mGeofencesAdded);
editor.Commit ();
SetButtonsEnabledState ();
Toast.MakeText (
this,
GetString (mGeofencesAdded ? Resource.String.geofences_added :
Resource.String.geofences_removed),
ToastLength.Short
).Show ();
} else {
var errorMessage = GeofenceErrorMessages.GetErrorString (this,
status.StatusCode);
Log.Error (TAG, errorMessage);
}
}
PendingIntent GetGeofencePendingIntent ()
{
if (mGeofencePendingIntent != null) {
return mGeofencePendingIntent;
}
//var intent = new Intent(this, typeof(Test));
//SendBroadcast(intent);
//return PendingIntent.GetBroadcast(this, 0, intent, PendingIntentFlags.UpdateCurrent);
var intent = new Intent(this, typeof(GeofenceTransitionsIntentService));
//SendBroadcast(intent);
return PendingIntent.GetService(this, 0, intent, PendingIntentFlags.UpdateCurrent);
}
public void PopulateGeofenceList ()
{
foreach (var entry in Constants.BAY_AREA_LANDMARKS) {
mGeofenceList.Add (new GeofenceBuilder ()
.SetRequestId (entry.Key)
.SetCircularRegion (
entry.Value.Latitude,
entry.Value.Longitude,
Constants.GEOFENCE_RADIUS_IN_METERS
)
.SetExpirationDuration (Constants.GEOFENCE_EXPIRATION_IN_MILLISECONDS)
.SetTransitionTypes (Geofence.GeofenceTransitionEnter |
Geofence.GeofenceTransitionExit)
.Build ());
}
}
void SetButtonsEnabledState ()
{
if (mGeofencesAdded) {
mAddGeofencesButton.Enabled = false;
mRemoveGeofencesButton.Enabled = true;
} else {
mAddGeofencesButton.Enabled = true;
mRemoveGeofencesButton.Enabled = false;
}
}
}
}
also i have tried making a broadcast reciever but it didnt helped me much
I see your code looks exactly like the sample you pull from the google developer page, and is the one many people is using more commonly at first. I myself was having issues with accuracy and missing fence transitions with that one too. I read that manually adding an instance of the previous location request package (LocationManager) and explicitly specifying GPS as a provider in high update mode can make it more accurate. That's how I have it working now. You can also try making your fences' radii wider, that way you will take into account the minimum wi-fi accuracy which is stated to be around 50m not considering drift.

android not getting calls on the other side when using gcm and sinch sdk

I'm trying to use gcm to start calls in sinch, I send the push notification and I get it on the other side but when I try to start a call I get null pointer exception in my service at mCall.addCallListener( );
this is the part of the gcm intent service where I get the notification and start sinch service :
{
String callId = intent.getExtras().getString("callId");
Intent intent3 = new Intent(this, SinchClientService.class);
intent3.setAction(SinchClientService.ACTION_START_CALL);
intent3.putExtra(SinchClientService.INTENT_EXTRA_CALLID, callId);
startService(intent3);
}
this is what I do in the sinch service:
else if(intent.getAction().equals(ACTION_START_CALL))
{
String callId = intent.getStringExtra(INTENT_EXTRA_CALLID);
if(callId != null)
{
startCall(callId);
}
}
public void startCall(String callId) {
if (mCallClient != null) {
Call call = mCallClient.getCall(callId);
CurrentCall.currentCall = call;
Intent intent = new Intent(this, CallService.class);
startService(intent);
}
}
and this is how I start sinch client:
private void startSinchClient(String id, String userName) {
mSinchClient = Sinch.getSinchClientBuilder().context(this).userId(id).
applicationKey(APP_KEY).applicationSecret(APP_SECRET).environmentHost(ENVIRONMENT).build();
mSinchClient.addSinchClientListener(this);
mSinchClient.setSupportCalling(true);
mSinchClient.setSupportMessaging(true);
mSinchClient.setSupportPushNotifications(true);
mSinchClient.setSupportActiveConnectionInBackground(false);
//mSinchClient.startListeningOnActiveConnection();
mMessageClient = mSinchClient.getMessageClient();
mMessageClient.addMessageClientListener(this);
mCallClient = mSinchClient.getCallClient();
mCallClient.addCallClientListener(this);
mSinchClient.checkManifest();
mSinchClient.start();
}
and this is my onIcommingCall method:
#Override
public void onIncomingCall(CallClient client, Call call) {
Log.d(TAG, "Incoming call");
CurrentCall.currentCall = call;
Intent intent = new Intent(this, CallService.class);
startService(intent);
}
and this is the part of my call service where I get null pointer exception:
if(CurrentCall.currentCall == null)
stopSelf();
mCall = CurrentCall.currentCall;
mCall.addCallListener(this);
Note: my call service implements call listener
I never get the call, can someone help me?
Edit this is how I initialize a call:
in the sinch service:
public void callFriend(String id) {
if (mCallClient != null) {
Call call = mCallClient.callUser(id);
CurrentCall.currentCall = call;
Intent intent = new Intent(this, CallService.class);
startService(intent);
}
}
in the call service:
#Override
public void onShouldSendPushNotification(Call call, List<PushPair> pushPairs) {
Log.d(LOG_TAG, "Should send push notification");
Log.d("payload", pushPairs.get(0).getPushPayload());
asyncTask = new sendPushNotifications(this, call.getRemoteUserId(), pushPairs, call.getCallId());
asyncTask.execute();
}
class sendPushNotifications extends AutoAsyncTask {
List<PushPair> pushPairs;
String message;
String senderId;
String message_id;
String time_stamp;
String callId;
public sendPushNotifications(Context context, String senderId, List<PushPair> pushPairs, String callId) {
super(context, false);
this.pushPairs = pushPairs;
this.senderId = senderId;
this.callId = callId;
}
#Override
protected Integer doInBackground(Void... params) {
boolean connectedToInternet = connManager.getNetworkInfo( ConnectivityManager.TYPE_WIFI).isConnected()
|| connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected();
if (connectedToInternet)
{
String regId;
//JSONArray arrayList = new JSONArray();
for(PushPair p: pushPairs)
{
regId = new String(p.getPushData());
//arrayList.put(regId);
UserFunctions.sendCallPushNotifications(senderId, regId, "call", callId);
}
asyncTask = null;
return 0;
}
else
{
asyncTask = null;
return 1;
}
}
#Override
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
if (result == 0)
{
Log.d("call push sent", "sent");
}
else if (result == 1)
{
Toast.makeText(getApplicationContext(),
"No Network Connection !!", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(
getApplicationContext(),
"Error occured,Please Try Again Later !!",
Toast.LENGTH_SHORT).show();
}
}
}
}
latest edit so I did what you said and I only get calls in the messaging activity, my new codes are:
in the call service:
#Override
public void onShouldSendPushNotification(Call call, List<PushPair> pushPairs) {
Log.d(LOG_TAG, "Should send push notification");
Log.d("payload", pushPairs.get(0).getPushPayload());
asyncTask = new sendPushNotifications(this, call.getRemoteUserId(), pushPairs, call.getCallId());
asyncTask.execute();
}
class sendPushNotifications extends AutoAsyncTask {
List<PushPair> pushPairs;
String message;
String senderId;
String message_id;
String time_stamp;
String callId;
public sendPushNotifications(Context context, String senderId, List<PushPair> pushPairs, String callId) {
super(context, false);
this.pushPairs = pushPairs;
this.senderId = senderId;
this.callId = callId;
}
#Override
protected Integer doInBackground(Void... params) {
boolean connectedToInternet = connManager.getNetworkInfo( ConnectivityManager.TYPE_WIFI).isConnected()
|| connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected();
if (connectedToInternet)
{
String regId;
String payload;
//JSONArray arrayList = new JSONArray();
for(PushPair p: pushPairs)
{
regId = new String(p.getPushData());
payload = new String(p.getPushPayload());
//arrayList.put(regId);
UserFunctions.sendCallPushNotifications(senderId, regId, "call", callId, payload);
}
asyncTask = null;
return 0;
}
else
{
asyncTask = null;
return 1;
}
}
#Override
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
if (result == 0)
{
Log.d("call push sent", "sent");
}
else if (result == 1)
{
Toast.makeText(getApplicationContext(),
"No Network Connection !!", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(
getApplicationContext(),
"Error occured,Please Try Again Later !!",
Toast.LENGTH_SHORT).show();
}
}
}
the gcm intent service:
else
{
String callId = intent.getExtras().getString("callId");
String payload = intent.getExtras().getString("payload");
Intent intent3 = new Intent(this, SinchClientService.class);
intent3.setAction(SinchClientService.ACTION_START_CALL);
intent3.putExtra(SinchClientService.INTENT_EXTRA_CALLID, callId);
intent3.putExtra(SinchClientService.INTENT_EXTRA_PAYLOAD, payload);
startService(intent3);
}
the sinch service:
else if(intent.getAction().equals(ACTION_START_CALL))
{
String callId = intent.getStringExtra(INTENT_EXTRA_CALLID);
if(callId != null)
{
startCall(callId);
}
}
public void startCall(String callId) {
/*if (mCallClient != null) {
Call call = mCallClient.getCall(callId);
CurrentCall.currentCall = call;
Intent intent = new Intent(this, CallService.class);
startService(intent);
}*/
if(INTENT_EXTRA_PAYLOAD != null)
{
if(mSinchClient.isStarted())
mSinchClient.relayRemotePushNotificationPayload(INTENT_EXTRA_PAYLOAD);
else
{
DatabaseHandler handler = new DatabaseHandler(this);
UserInfo info = handler.getUserDetails();
startSinchClient(String.valueOf(info.uid), info.name);
String gcm_regId = ChatDatabaseHandler.getInstance(this).getGcmRegId();
mSinchClient.registerPushNotificationData(gcm_regId.getBytes());
}
}
}
#Override
public void onIncomingCall(CallClient client, Call call) {
Log.d(TAG, "Incoming call");
/*if(INTENT_EXTRA_CALLID != null)
{
CurrentCall.currentCall = mCallClient.getCall(INTENT_EXTRA_CALLID);
INTENT_EXTRA_CALLID = null;
}*/
CurrentCall.currentCall = call;
Intent intent = new Intent(this, CallService.class);
startService(intent);
}
that is also what I do when I bind and unbind with the service:
#Override
public boolean onUnbind(Intent intent) {
mSinchClient.stopListeningOnActiveConnection();
return super.onUnbind(intent);
}
#Override
public IBinder onBind(Intent intent) {
mSinchClient.startListeningOnActiveConnection();
return mServiceInterface;
}
You seem to be missing the code where you actually send the Sinch-specific payload in your push, you should use PushPair.getPushPayload() to retrieve it in the onShouldSendPushNotification callback and make sure to include that in the push message.
After you add that, you need to retrieve the payload on the receiver side and pass in to relayRemotePushNotificationPayload(String payload). This will give you the onIncomingCall callback on the receiver side.

App widget fetch data from server

I have developed a widget which will fetch the data from a server and do some modifications and display in widget.
I have a ALARM manager which starts a service in every 10 sec and service fetches data with async task and display.
It consumes a lot of CPU usage.
Kindly help if I can change the code design and make the widget more effective.
I use Jsoup to connect and fetch data.
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
Log.d("Widget : " , "Inside onUpdate widget");
// To prevent any ANR timeouts, we perform the update in a service
final AlarmManager m = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
final Calendar TIME = Calendar.getInstance();
TIME.set(Calendar.MINUTE, 0);
TIME.set(Calendar.SECOND, 0);
TIME.set(Calendar.MILLISECOND, 0);
final Intent i = new Intent(context, UpdateService.class);
if (service == null)
{
service = PendingIntent.getService(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
}
m.setRepeating(AlarmManager.RTC, TIME.getTime().getTime(), 100 * 60, service);
}
public static class UpdateService extends Service {
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// System.out.println("Inside config change ");
enableControls(this);
}
#Override
public void onStart(Intent intent, int startId) {
// Build the widget update for today
mContext = this;
Log.d("Widget : " , "Service started");
enableControls(this);
}
public static void enableControls(Context context){
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_status);
Intent active = new Intent(context, MyWidgetProvider.class);
active.setAction(ACTION_WIDGET_REFRESH);
active.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0);
pushWidgetUpdate(context, remoteViews);
fetchStatus();
}
public static void fetchStatus(){
new AsyncTask<String, Void, String>() {
#Override
protected String doInBackground(String... urls) {
try {
if(getWiFiStatus(mContext) == true ){
boolean getRedirectedURL = false;
String url,finalURL;
finalURL = "http://mobile.server.status";
Document doc = Jsoup.connect(finalURL).get();
while(getRedirectedURL == false){
Log.d(LOG_TAG,"inside while loop ---- : " + getRedirectedURL);
doc = Jsoup.connect(finalURL).get();
Log.d(LOG_TAG,"Complete doc: " + doc);
// System.out.println("Found the doc : " +doc.toString().contains("status"));
// Log.d(LOG_TAG,"Whole data third :"+doc);
// System.out.println("Printing redirected URL " + (docHead.select("meta")));
if(doc.toString().contains("status")){
getRedirectedURL = true;
break;
}
else
getRedirectedURL = false;
Elements docHead = doc.select("meta");
for(Element emt :docHead) {
url =null;
//Log.d(LOG_TAG,"Value boolean :"+emt.getElementsByAttribute("http-equiv").toString().toLowerCase().contains("url"));
if(emt.getElementsByAttribute("http-equiv").toString().toLowerCase().contains("url") ){
//getRedirectedURL = true;
url = emt.getElementsByAttribute("http-equiv").toString().toLowerCase().split("url=")[1].toString();
if (emt.getElementsByAttribute("http-equiv").toString().toLowerCase().contains("http://")){
finalURL = null;
finalURL = url.split("\"")[0].toString();
}
else
finalURL = finalURL + url.split("\"")[0].toString();
//Log.d(LOG_TAG,"Final URL :"+finalURL);
}
// else
// getRedirectedURL = false;
}
}
Log.d(LOG_TAG,"Final URL :"+finalURL);
doc = Jsoup.connect(finalURL).get();
Document noFramesDoc = Jsoup.parseBodyFragment(doc.toString());
}
else{
refreshStatus(mContext);
}
} catch (UnknownHostException exception){
System.out.println("Inside unknown host : ");
}
catch (Exception e) {
Log.d(LOG_TAG,"other Exception found :"+e.toString());
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(String result) {
if(mContext != null)
}
#Override
protected void onCancelled() {
}
}.execute();
}

Categories

Resources