Note that there are some explanatory texts on larger screens.

plurals
  1. PO'Share via' application that runs without a View
    primarykey
    data
    text
    <p>I want to write an app that sits in the 'Share via' menu (for quickly emailing myself links to things I find on the web or look at in RSS readers) For this I'm declaring my app with an intent.action.SEND intent-filter:</p> <pre><code> &lt;activity android:name="uk.co.baroquedub.checkit.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.SEND" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="text/plain" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>Here's a skeleton of the MainActivity package</p> <pre><code>package uk.co.baroquedub.testcheck; import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // real code here grabs URL from intent then emails it as an asyncTask: doSendTask task = new doSendTask(); task.execute(new String[] { "urlString" }); } protected void showDialog (String response){ Toast.makeText(this, response, Toast.LENGTH_SHORT).show(); finish(); } private class doSendTask extends AsyncTask&lt;String, Void, String&gt; { @Override protected String doInBackground(String... urls) { String response = ""; // Real code here sends the email // Simulate waiting for the email to be sent: try { Thread.sleep(5000); response = "Waited"; } catch (InterruptedException ex) { } return response; } @Override protected void onPostExecute(String result) { showDialog(result); } } } </code></pre> <p>The problem is that my app is opening on top of the browser (a white screen appears with a title bar showing the name of the app) - which is stopping the browser from being accessible until the 'wait' is finished (hence defeating the purpose of wrapping my sendEmail functionality within an asyncTask). </p> <p>See: <a href="http://screencast.com/t/NbTOxcLJxu" rel="nofollow noreferrer">screencast for demo of problem</a></p> <p>See: <a href="https://stackoverflow.com/questions/13704146/app-using-asynctask-still-hogging-the-ui-thread">related question with full code</a> </p> <p>Can anyone tell me how I can have my app start (from the 'Share via' menu) and execute my code but without actually having a 'View' (if that's the right terminology for the blank screen and title bar)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload