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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -