java - how can i call a method with a startActivity(Intent) from another class? -
i want call sendpicture()
class. seems can't make sendpicture()
static type because has startactivity()
in it. wondering if possible call class if so, how?
sendpicture()
code:
public static void sendpicture() { file f=new file(environment.getexternalstoragedirectory().getabsolutepath()); intent sendintent = new intent(intent.action_send); sendintent.putextra("address", "number"); sendintent.putextra("sms_body", "see attached picture"); sendintent.putextra(intent.extra_stream, uri.fromfile(f)); sendintent.settype("image/jpg"); startactivity(sendintent); }
startactivity() method of context need have reference context. might try getapplicationcontext().startactivity(sendintent), or pass context static method , use reference.
Comments
Post a Comment