title: startActivityForResult is not recognized as function in AsyncTask
body: <p>I am making a phonegap project. I have made a native plugin in android for it. In it, AsyncTask is being called too. In it, I have <code>context.startActivity(intent)</code> function. I want to perform a task after this Activity completes. I found a solution to use <code>context.startActivityForResult(intent,i)</code> instead. But this function is not recognizable.</p>
  
  <p>Then I tried,</p>
  
  <pre><code>((Activity) context).startActivityForResult(intent,1);
  </code></pre>
  
  <p>as per</p>
  
  <p><a href="https://stackoverflow.com/questions/20656937/startactivityforresult-not-working-in-asynctask">StartActivityForResult not working in AsyncTask</a></p>
  
  <p>But at time of <code>startActivityForResult</code>,i got file installation error.</p>
  
  <p>My code is as follows-</p>
  
  <pre><code> public class MyPlugin extends CordovaPlugin
      {
          Context context;
          CallbackContext callback;
          @Override
          public void initialize(CordovaInterface cordova, CordovaWebView webView) 
          {
              super.initialize(cordova, webView);    
          }
          @Override
          public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException 
          {   
                  context=this.cordova.getActivity().getApplicationContext();
                  callback=callbackContext;
  
                  if (action.equals("plugin1"))
                  { 
                       System.out.println("Inside plugin1");
                       String myurl = args.getString(0);
                       if(haveNetworkConnection()==true)
                       {
                           System.out.println("Network connected");
                           new DownloadManager().execute(myurl);
                           return true;
                       }
                       else
                       {
                           System.out.println("Network not connected");
                           callbackContext.error("Internet connection is not available.");
                           return false;
                       }
                  }
  
                  callbackContext.error("Some error has occured.Please try later.");
                  return false;
  
          }
  
          public class DownloadManager extends AsyncTask&lt;String, String, String&gt; 
          {
              @Override
              public String doInBackground(String... arg0)
              {
                  try
                  {
                      //Knowing imei number
                      TelephonyManager mngr = (TelephonyManager)context.getSystemService(context.TELEPHONY_SERVICE); 
                      String imei_device=mngr.getDeviceId();
                      //downloading and installing app
                      downloadapk(arg0[0]);
                      installapk();
                      PluginResult result = new PluginResult(PluginResult.Status.OK, "success");
                      result.setKeepCallback(true);
                      callback.success("Operation completed!!");
                      return null;
                  }
                  catch(Exception e)
                  {
                      callback.error("Some problem occured.Try again later");
                      return null;
                  }   
              }
           }
          public void installapk()
          {
               try
               { 
                  Intent intent=new Intent(Intent.ACTION_VIEW);
                  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  intent.setDataAndType(
                  Uri.fromFile(new File(Environment.getExternalStorageDirectory()+"/"+fileName)),"application/vnd.android.package-archive");
                  ((Activity) context).startActivityForResult(intent,1);
               }
               catch (Exception e) 
               {
                  Log.e("File installing Error", e.getMessage());
                  System.out.println(e.getMessage());
                  callback.error("Installation Failed.Please try later");
               }
           }
          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
  
                if (requestCode == 1) //check if the request code is the one you've sent
                {
                       if (resultCode == Activity.RESULT_OK) 
                       {
                          System.out.println("Result is OK");
                        }
                       else
                       {
                           System.out.println("Result is not OK");    
                        }
                }
  
  
              super.onActivityResult(requestCode, resultCode, data);
  
          }
  </code></pre>
  
  <p>Thanx in advance. </p>