Android Question eligible "OPEN WITH" for own file extension (*.abc)

Tayfur

Well-Known Member
Licensed User
Longtime User
hello;

I want to add eligible option for "OPEN WTIH"

For example, I want to open a "*.html" file, after I see Chrome, Firework. etc.
Or... I want to open a "*.pdf" file, after I see Chrome, AdobeAcrobat etc.
Or... I want to open a "*.jpg" file, after I see Gallery, Airdroid etc.

Now; I have spcial file extension.(from exsample xxxx.abc) and
I want see my app in "OPEN WITH " menu when open "xxx.abc" in file maneger.
How can I do it???? how can I add Android system???
Screenshot_2016-04-05-11-47-07.png
 

moster67

Expert
Licensed User
Longtime User
Never tried it myself but found this in the forum:

Code to insert in Manifest:

B4X:
AddActivityText(main,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/x-vcard" />
</intent-filter>)
Replace mime-type with your extension.

Then in your app you need to act on the request somehow. Again a search in the forum showed this thread:

As I said, I never tried it but it may get you going in the right direction.

Hope this is what you're looking for...
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Never tried it myself but found this in the forum:

Code to insert in Manifest:

B4X:
AddActivityText(main,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/x-vcard" />
</intent-filter>)
Replace mime-type with your extension.

Then in your app you need to act on the request somehow. Again a search in the forum showed this thread:

As I said, I never tried it but it may get you going in the right direction.

Hope this is what you're looking for...

tgtp is own file extension

http://developer.android.com/guide/topics/manifest/data-element.html

B4X:
<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:scheme="file" />
  <data android:mimeType="*/*" />
  <data android:pathPattern=".*\\.tgtp" />  
  <data android:host="*" />
</intent-filter>
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
have you tried
too?

or maybe

B4X:
AddActivityText(main,
<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:scheme="file" />
  <data android:mimeType="*/*" />
  <data android:pathPattern="\\*\\*.tgtp" /> 
  <data android:host="*" />
</intent-filter>)

No.. no .. (

do you have a little working sample ?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Found this post by googling:

See these posts:
http://stackoverflow.com/questions/2037551/how-to-open-email-attachment-in-my-app-on-android
http://stackoverflow.com/questions/...ctivity-from-email-client-attachment-view-int
http://stackoverflow.com/questions/4799576/register-new-file-type-in-android

For my app, I ended up using:
<activity android:name=".ImportFileDetailsActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.mmr" />
<data android:pathPattern=".*..*..*..*..*..*.mmr" />
<data android:pathPattern=".*..*..*..*..*.mmr" />
<data android:pathPattern=".*..*..*..*.mmr" />
<data android:pathPattern=".*..*..*.mmr" />
<data android:pathPattern=".*..*.mmr" />
<data android:pathPattern=".*.mmr" />
</intent-filter>
</activity>

Once I installed and started my app, I had to "Force Stop" the gmail app before trying again to get it to pick up my file type.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
its works...
@moster67 and @DonManfred Many Many thanks... :):):):)

Now; next step : I must found file path/name etc. I will reserch it.


B4X:
AddActivityText(main,
         <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
                <data android:scheme="https" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
                <data android:scheme="content" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
                <data android:scheme="file" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
            </intent-filter>
)
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
its works...
@moster67 and @DonManfred Many Many thanks... :):):):)

Now; next step : I must found file path/name etc. I will reserch it.


B4X:
AddActivityText(main,
         <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
                <data android:scheme="https" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
                <data android:scheme="content" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
                <data android:scheme="file" android:host="*"
                    android:pathPattern=".*\\.tgtp" />
            </intent-filter>
)

Now is everything is ok. Thank you for helps.

B4X:
ub Activity_Resume
     Dim in As Intent
in = Activity.GetStartingIntent
If in <> Null Then
    
        Log(in.GetExtra("path"))
        Dim XmlData As String
   
        XmlData = in.GetData
     
       
        Msgbox(XmlData,"")
'       Send_Make_somthing(in)
'       Activity.Finish
       Return
  
End If
End Sub
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
This is for ZIP files.
it need a special line.
<data android:mimeType="application/zip" />


B4X:
AddActivityText(main,
         <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:mimeType="application/zip" />
                <data android:scheme="http" android:host="*"
                    android:pathPattern=".*\\.zip" />
                <data android:scheme="https" android:host="*"
                    android:pathPattern=".*\\.zip" />
                <data android:scheme="content" android:host="*"
                    android:pathPattern=".*\\.zip" />
                <data android:scheme="file" android:host="*"
                    android:pathPattern=".*\\.zip" />
            </intent-filter>
)
 
Upvote 0
Top