Android - Custom Class imports differently not sure why -


i have custom class in android, simple call download , start share intent on files in app come specific url

import android.app.activity; import android.app.progressdialog; import android.content.context; import android.content.intent; import android.os.asynctask; import android.os.environment;  import java.io.file;  public class downloadandshare {     activity activity;     context context;     progressdialog dialog;     string url;      public downloadandshare(activity activity, context context, string url) {         this.activity = activity;         this.context = context;         this.url = url;     }      public void startsharing()     {         //start shareintent file         file filewithinmydir = environment.getexternalstoragedirectory();         string[] fn = url.split("/");         string filename = fn[fn.length-1];         file storagefolder = new file(filewithinmydir.tostring() + "/myappname");         //if storage folder not yet exists, create         if(!storagefolder.exists()){             storagefolder.mkdirs();         }         final string path = filewithinmydir.tostring() + "/myappname/" + filename;         //check if file exists in internal storage         file file = new file(path.replace(" ", ""));         if (!file.exists()){             //file not exists, download internal storage use             new executedownloadandshare().execute(path.replace(" ", ""), url);         } else {             intent shareintent = globals.getshareintent(path.replace(" ", ""), false);             activity.startactivity(intent.createchooser(shareintent, "share using..."));         }     }      private class executedownloadandshare extends asynctask<string, integer, integer> {          string filepath;          @override         protected void onpreexecute() {             dialog = progressdialog.show(context, "", context.getresources().getstring(r.string.general_msg_please_wait));         }          @override         protected integer doinbackground(string... params) {             filepath = params[0];             try {                 globals.downloadfromurl(params[0], params[1]);             } catch (exception e) {                 return appconstants.status_fail;             }             return appconstants.status_success;         }          @override         protected void onpostexecute(integer result) {             dialog.dismiss();             intent shareintent = globals.getshareintent(filepath, false);             activity.startactivity(intent.createchooser(shareintent, "share using..."));         }     } } 

for reason, when try create instance of inside 1 of files, needs have full com.myappname.android.mycustomclass mycustomclass = new com.myappname.android.mycustomclass(); in order files have mycustomclass mycustomclass = new mycustomclass() , works fine, in few files wants entire path.

does have insight why occurs? both files call both extending fragment, , 1 works while other needs full path. thought maybe private method should public etc, can't find wrong.

clean project , uninstall app device/emulator before starting again. if not help, restart android studio.


Comments