Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:...

Code to open Application(user Created Project in list of options menu while opening that atachment),whenever clicks the Attachment exists in your mail inbox(any email) in Android..

Refer links:

http://stackoverflow.com/questions/3497350/android-launching-an-application-chooser-with-appropriate-list-of-applications

http://stackoverflow.com/questions/11295961/how-to-return-workable-filepath

http://stackoverflow.com/questions/12426020/how-do-i-stop-xml-email-attachment-translating-to-html-in-the-gmail-app

http://stackoverflow.com/questions/2037551/how-to-open-email-attachment-in-my-app-on-android


OptionsInMailAttachmntsOpenActivity.java:-

package org.dharani.mailAttacmntOpen;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import android.os.Bundle;

public class OptionsInMailAttachmntsOpenActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        Intent i = getIntent();
        if(i == null) return;
        Uri u = i.getData();
        if(u == null) return;
        String scheme = u.getScheme();

        System.out.println("******my application-1***********");
        if(ContentResolver.SCHEME_CONTENT.equals(scheme))
        {
            try
            {
                ContentResolver cr = getContentResolver();
                AssetFileDescriptor afd = cr.openAssetFileDescriptor(u, "r");
                long length = afd.getLength();
                byte[] filedata = new byte[(int) length];
                InputStream is = cr.openInputStream(u);
                if(is == null) return;
                try
                {
                    is.read(filedata, 0, (int) length); 
                   
                    /*Intent intent = new Intent(Intent.ACTION_VIEW);
                    Uri uri = Uri.fromFile(new File(chosenFile));
                    intent.putExtra(Intent.ACTION_VIEW, uri);
                    Intent chooser = Intent.createChooser(intent, "Prashant");
                    startActivity(chooser);*/
                    //Util.loadOTDRFileFromByteArray(filedata);
                }
                catch(IOException e)
                {
                    return;
                }  
            }
            catch(FileNotFoundException e)
            {
                return;
            }
        }
        else
        {
            System.out.println("******my application-2***********");
            String filePath = u.getEncodedPath();
            if(filePath == null) return;
            //Util.loadOTDRFileFromPath(filePath);
        }
    }
}


AndroidManifest.xml:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.dharani.mailAttacmntOpen"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />
  
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".OptionsInMailAttachmntsOpenActivity"
            android:label="@string/app_name" >
           
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
           
             <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
                <data android:scheme="file" />
                <data android:host="*" />
                <data android:port="*" />
                <data android:pathPattern=".*..*..*..*..*..*.trc" />
                <data android:pathPattern=".*..*..*..*..*.trc" />
                <data android:pathPattern=".*..*..*..*.trc" />
                <data android:pathPattern=".*..*..*.trc" />
                <data android:pathPattern=".*..*.trc" />
                <data android:pathPattern=".*.trc" />
            </intent-filter>

            <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="*/*" />
            <data android:pathPattern=".*\\.xyz" />
            </intent-filter>
           
        </activity>
    </application>

</manifest>

Note:  Procedure To execute this project,first run this project,
-> after open ur Gmail a/c ->goto Inbox..
-> open any mail having attachment
-> click preview
Then u can see ur project in options menu

Comments