package com.nitrr.nrnotifier;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.utils.URLEncodedUtils;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 import android.app.Activity;
 import android.content.Intent;
 import android.net.ParseException;
 import android.net.Uri;
 import android.os.Bundle;
 import android.util.Log;
 import android.webkit.MimeTypeMap;
 import android.widget.Toast;
public class Act3 extends Activity
{
 static InputStream is = null;
 String result = null;
  public void onCreate(Bundle savedInstanceState)
  {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.third);
        String id=getIntent().getExtras().getString("pid");
        try
        {
             List<NameValuePair> params = new ArrayList<NameValuePair>();
             params.add(new BasicNameValuePair("id", id));
            DefaultHttpClient httpClient = new DefaultHttpClient();
            String paramString = URLEncodedUtils.format(params, "utf-8");
            String url="http://10.0.2.2/ndesc.php";
            url += "?" + paramString;
            HttpGet httpGet = new HttpGet(url);
            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();
        }
        catch(Exception se){
            Log.e("log_tag", "Error in http connection"+se.toString());
        }
        //convert response to string
        try{
        BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
              StringBuilder sb = new StringBuilder();
            sb.append(reader.readLine() + "\n");
            String line="0";
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
           System.out.println(result);
        }catch(Exception e){
            Log.e("log_tag", "Error converting result "+e.toString());
        }
        try{
            JSONArray jArray = new JSONArray(result);
            JSONObject json_data = null;
            for(int i = 0; i < jArray.length(); i++){
                    json_data = jArray.getJSONObject(i);
                   String filepath=json_data.getString("ndesc");
                   Uri fileUri = Uri.fromFile(new File(filepath));
                   Uri new_uri = Uri.parse("file://"
                           + fileUri.getPath());
                   Intent intent = new Intent(Intent.ACTION_VIEW,
                           new_uri);
                   MimeTypeMap myMime = MimeTypeMap.getSingleton();
                   String fileExt = filepath.substring(filepath
                           .lastIndexOf(".") + 1);
                   String mimeType = myMime
                           .getMimeTypeFromExtension(fileExt);
                   intent.setDataAndType(new_uri, mimeType);
                   startActivity(intent);
            }
            }catch(JSONException e2)
            {  e2.printStackTrace();
                Toast.makeText(getBaseContext(), "No User Found", Toast.LENGTH_LONG).show();
            }catch (ParseException e1){
                e1.printStackTrace();
            } 
 }
}
This is my code where I'm storing fetched filepath from server database I filetype variable and then processing it..But I couldn't get my expected output i.e. the file itself..the code is throwing Exception and I get
no android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///http:/127.0.0.1/45_Hindi Theme 1 & 2 (Class-IX).pdf typ=application/pdf }
please help me to fix this.
 
     
     
    