问题:导入项目到Eclipse提示:“the type R is already defined”
解决方法:删掉src文件夹下的R.java文件,刷新工程即可
参考:http://bbs.csdn.net/topics/350161951?page=1#post-352784398
问题:在安卓模拟器中运行时提示“PANIC: Could not open”
解决方法:设置ANDROID_SDK_HOME环境变量及修改eclipse\configuration.settings\org.eclipse.ui.ide.prefs内容。
参考:http://blog.csdn.net/top_code/article/details/12008269
问题:Eclipse关联JAVA源文件后,双击JAVA源文件提示“Failed to create the Java Virtual Machine”
解决方法:修改eclipse解压目录下的配置文件eclipse.ini内的”--launcher.XXMaxPermSize 256M“改为”--launcher.XXMaxPermSize 128M“(共两处)。
参考:http://blog.csdn.net/rflyee/article/details/8958165
问题:安装到真机测试,提示“Installation error: INSTALL_CANCELED_BY_USER”
解决办法:在手机上需要手动点击确定才可以安装。
参考:http://bbs.xiaomi.cn/thread-8072542-1-1.html
生成jar包供调用:http://www.cnblogs.com/vivid-stanley/archive/2012/02/18/2357182.html
Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts
5/01/2014
10/28/2013
Tips & Tricks for web service query via Tasker
Sometimes we want to retrieve useful information from internet via Tasker, e.g. weather forecast, phone number area etc. We can use “HTTP POST/GET” action ATM. In general, the specific information which we want, embedded in the webpage we query from. It will need much more seconds and data traffic, and we have to use some complicated and annoyed steps, e.g. “Variable Split” or “Variable Search Replace” etc., to extract the specific information from it. Now I have some tips and tricks for this situation. Here I suppose you have known how to use “HTTP POST/GET” action via Tasker. Here we go.
-------------------------------------------------------------
Almost all webpages we retrieved, consist a lot of useless parts. So why not use other professional web services with API documented? These professional web services often provide specific API and refined output, e.g. output in XML, JSON format. Make good use of Google Search to find these professional web services first, guys.
For example, how to get the attribution and operator information from specific phone number in China? I can do it with with the free web service here, and it provide detailed API. With “HTTP GET(URL: http://www.sososjw.com/json?Tel=13888888888)”, we can get refined output in internal variable “%HTTPD” about the phone number 13888888888. Here is the content of “%HTTPD” for it:
{"Tel":"1388888","Province":"云南","City":"昆明","AreaCode":"0871","PostCode":"650000","Corp":"中国移动","Card":"GSM"}
It’s in JSON format, and it’s very simple and useful. Here I suggest that you’d better use “Javascript(let)” action to parse the value of element. The script below will flash ‘昆明’ , the value of “City” element for former ouput.
var info = JSON.parse(global("HTTPD"));
flash(info.City);
Also we can get weather forecast from professional web service.
e.g.
for city ‘大连(Da lian)’ in China http://m.weather.com.cn/data/101070201.html
A example for San Franciso http://api.wunderground.com/api/Your_Key/forecast/q/CA/San_Francisco.json
Perhaps you need learn some tutorial lessons about JSON and javascript from online W3School. Maybe you can use app “JOSN Viewer” to format raw JSON data and view the elements in tree structure.
"JSON Viewer" online: http://www.jsoneditoronline.org/
"JSON Viewer" for Win: http://jsonviewer.codeplex.com/ http://tomeko.net/software/JSONedit/index.php
"JSON Viewer" for Android: https://play.google.com/store/apps/details?id=eu.borzaindustries.jsondroid&hl=zh_CN
---------------------------------------------------
Sometimes you couldn’t find any web service with API.
There is a little trick that you can try its WAP service for help. Usually, some webpage use a refined WAP page for lower end mobile browser. You’ll feel lucky if the specific web service with a WAP page provided and you find it really available.
e.g. A weather forecast WAP page about Shanghai in China: http://www.weather.com.cn/wap/weather/101020100.shtml
For those who are not so lucky, there is another trick that you can use online RSS service to extract specific information from webpage and burned it into RSS feed URL. Here I strongly recommend you’d better use ‘feed43’ or ‘Yahoo Pipes’ to do the work. The ‘Yahoo Pipes’ is much more powerful than the former one. I’ve use the feed43 service to extract and burn a RSS feed about MIUI daily motto in my another article.
----------------------------------------------
Sometimes you’ll find the output of web service is useful, but not so concise, especially a little webpage with lots of useless HTML tags. I suggest that you can use “Variable -> Variable Convert –‘Html to text’” function to convert ‘%HTTPD’ into Text, then you can process the text more concisely.
OK. That’s all from my experience. Although I haven’t share you a plenty of online web service, you’ll find things become much more easier if you know the tricks. Principle or thoughts goes first, I always believe in this.
-------------------------------------------------------------
Almost all webpages we retrieved, consist a lot of useless parts. So why not use other professional web services with API documented? These professional web services often provide specific API and refined output, e.g. output in XML, JSON format. Make good use of Google Search to find these professional web services first, guys.
For example, how to get the attribution and operator information from specific phone number in China? I can do it with with the free web service here, and it provide detailed API. With “HTTP GET(URL: http://www.sososjw.com/json?Tel=13888888888)”, we can get refined output in internal variable “%HTTPD” about the phone number 13888888888. Here is the content of “%HTTPD” for it:
{"Tel":"1388888","Province":"云南","City":"昆明","AreaCode":"0871","PostCode":"650000","Corp":"中国移动","Card":"GSM"}
It’s in JSON format, and it’s very simple and useful. Here I suggest that you’d better use “Javascript(let)” action to parse the value of element. The script below will flash ‘昆明’ , the value of “City” element for former ouput.
var info = JSON.parse(global("HTTPD"));
flash(info.City);
Also we can get weather forecast from professional web service.
e.g.
for city ‘大连(Da lian)’ in China http://m.weather.com.cn/data/101070201.html
A example for San Franciso http://api.wunderground.com/api/Your_Key/forecast/q/CA/San_Francisco.json
Perhaps you need learn some tutorial lessons about JSON and javascript from online W3School. Maybe you can use app “JOSN Viewer” to format raw JSON data and view the elements in tree structure.
"JSON Viewer" online: http://www.jsoneditoronline.org/
"JSON Viewer" for Win: http://jsonviewer.codeplex.com/ http://tomeko.net/software/JSONedit/index.php
"JSON Viewer" for Android: https://play.google.com/store/apps/details?id=eu.borzaindustries.jsondroid&hl=zh_CN
---------------------------------------------------
Sometimes you couldn’t find any web service with API.
There is a little trick that you can try its WAP service for help. Usually, some webpage use a refined WAP page for lower end mobile browser. You’ll feel lucky if the specific web service with a WAP page provided and you find it really available.
e.g. A weather forecast WAP page about Shanghai in China: http://www.weather.com.cn/wap/weather/101020100.shtml
For those who are not so lucky, there is another trick that you can use online RSS service to extract specific information from webpage and burned it into RSS feed URL. Here I strongly recommend you’d better use ‘feed43’ or ‘Yahoo Pipes’ to do the work. The ‘Yahoo Pipes’ is much more powerful than the former one. I’ve use the feed43 service to extract and burn a RSS feed about MIUI daily motto in my another article.
----------------------------------------------
Sometimes you’ll find the output of web service is useful, but not so concise, especially a little webpage with lots of useless HTML tags. I suggest that you can use “Variable -> Variable Convert –‘Html to text’” function to convert ‘%HTTPD’ into Text, then you can process the text more concisely.
OK. That’s all from my experience. Although I haven’t share you a plenty of online web service, you’ll find things become much more easier if you know the tricks. Principle or thoughts goes first, I always believe in this.
Reference:
1. something wrong with JSON.parse()?
2. Tasker来电归属地设置
3. 开源免费天气预报接口API以及全国所有地区代码!!(国家气象局提供)
4. Sickbeard today's shows to pebble
(Android+Tasker)
10/07/2013
Homemade Tasker Creations for Home Use
Here is some of my homemade tasker creations using scenes for home use.
Screenshots:
Wifi Password Viewer:
Shell Command Debugger:
Calculator:
Tasks Search & Run:
Special Symbols Pad:
Screen Filter:
Screenshots:
Wifi Password Viewer:
Shell Command Debugger:
Lyrics Show for PowerAMP:
Calculator:
Tasks Search & Run:
Special Symbols Pad:
Screen Filter:
9/22/2013
Mark Unread Sms As Read Thoroughly via Tasker
For quite some time, I use a task to mark unread sms as read programmatically via Tasker. But these method worked not so effectively.
Firstly, I adopt the database-process-directly way. With a specific SQL syntax, I can mark all unread sms as read. Like this:
Run Shell [ Command: sqlite3 /data/data/com.android.providers.telephony/databases/mmssms.db "update sms set read=1 where read=0" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: Continue Task After Error:On ]
Yes, it mark the unread sms as read. But it can’t refresh the unread count in “Messaging” app. And it can’t clear the unread notification in notification bar.
Then I tried the “SL4A+Python” method(refer here). Yes, it can mark unread sms as read and reset the unread count in “Messaging App”. But it can’t clear the unread notification too.
With the “SL4A+Python” method, we made a step forward. But it’s not very perfect. As for notification problem, I had looked up some information. It’s not allowed to clear notification of other app programmatically in android. The notification can be cleared by the tapping of user or by the app itself. We will be taken to the main window of app when we tapped the specific notification normally. And it seems not to be a friendly way. So we can consider about the other way. But app will not clear its notification at our sweet will. I’ve been stuck here for a long time.
Until recently, the principle behind "Launch Camera App" inspired me to try to do something similar about the package of "Messaging" app.
I tried it and it proves me right on MIUI 3.9.6. Now I can mark unread sms as read thoroughly via Tasker! Here is the flowchart:
More: Clear An App's Notification
Firstly, I adopt the database-process-directly way. With a specific SQL syntax, I can mark all unread sms as read. Like this:
Run Shell [ Command: sqlite3 /data/data/com.android.providers.telephony/databases/mmssms.db "update sms set read=1 where read=0" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: Continue Task After Error:On ]
Yes, it mark the unread sms as read. But it can’t refresh the unread count in “Messaging” app. And it can’t clear the unread notification in notification bar.
Then I tried the “SL4A+Python” method(refer here). Yes, it can mark unread sms as read and reset the unread count in “Messaging App”. But it can’t clear the unread notification too.
With the “SL4A+Python” method, we made a step forward. But it’s not very perfect. As for notification problem, I had looked up some information. It’s not allowed to clear notification of other app programmatically in android. The notification can be cleared by the tapping of user or by the app itself. We will be taken to the main window of app when we tapped the specific notification normally. And it seems not to be a friendly way. So we can consider about the other way. But app will not clear its notification at our sweet will. I’ve been stuck here for a long time.
Until recently, the principle behind "Launch Camera App" inspired me to try to do something similar about the package of "Messaging" app.
I tried it and it proves me right on MIUI 3.9.6. Now I can mark unread sms as read thoroughly via Tasker! Here is the flowchart:
More: Clear An App's Notification
Launch Camera App With Predefined Settings via Tasker
During the mid-autumn vacation, someone requested help in my QQ troop of Tasker (ID: 333174356), about how to launch camera app with predefined parameters(e.g. picture size, picture quality, and so on) for specific situation. Because of some other reason, I just give him an idea to try, and I haven’t put it into effect. After the vacation, I have chance to try my idea and it turns out the idea is right. Realized the principle behind the idea may be helpful to more similar situations, hereinafter I will explain the idea in detail, and take the “picture size” parameter of rear camera for example.
Firstly, we know that the “Media -> Take Photo” action will open the camera with custom parameters and then take photo automatically. Unfortunately, we can’t use this action to open the camera with custom parameters just for preview, then take photo manually.
I know a specific intent, which named “android.media.action.IMAGE_CAPTURE” in android, can launch the camera app with preview window. I’ve tried it before. And I find it not support camera parameters. I mean that it only open the camera window with default settings which we can’t change it programmatically.
Below shows the intent I tried:
Send Intent [ Action:android.media.action.IMAGE_CAPTURE Cat:Default Mime Type: Data: Extra: Extra: Package:com.android.camera Class:com.android.camera.Camera Target:Activity ]
As everyone knows, most settings are stored in the format of file, even databases. After some digging, I found the file (data/data/com.android.camera/shared_prefs/com.android.camera_xiaomi_preferences_0.xml) contains the “picture size” setting. We can change the value of “pref_camera_picturesize_key” node in the xml file programmatically. Then we launch the camera app. At last, we can restore the “picture size” setting.
Be careful! If you only follow these steps, the loaded camera app will not meet the desired effect. Because the camera app maybe can’t realize some settings changed, I think. There is a trick that you can disable and enable the app to take into effect. It’s very probably that the app will re-read the preferences file after the disable and enable operation. I guess the camera app read the settings and always runs in background when the device boots. We can disable and enable an app manually in android.
Of course, we can do this with the “Secure Setting” plugin for Tasker.
As for how to change the setting string in the preferences file, you can use shell script(especially “sed”, “awk” command) or use two files for renaming and swapping.
Here is the flowchart of the whole idea. (I've tried it successfully in MIUI 3.9.6)
Firstly, we know that the “Media -> Take Photo” action will open the camera with custom parameters and then take photo automatically. Unfortunately, we can’t use this action to open the camera with custom parameters just for preview, then take photo manually.
I know a specific intent, which named “android.media.action.IMAGE_CAPTURE” in android, can launch the camera app with preview window. I’ve tried it before. And I find it not support camera parameters. I mean that it only open the camera window with default settings which we can’t change it programmatically.
Below shows the intent I tried:
Send Intent [ Action:android.media.action.IMAGE_CAPTURE Cat:Default Mime Type: Data: Extra: Extra: Package:com.android.camera Class:com.android.camera.Camera Target:Activity ]
As everyone knows, most settings are stored in the format of file, even databases. After some digging, I found the file (data/data/com.android.camera/shared_prefs/com.android.camera_xiaomi_preferences_0.xml) contains the “picture size” setting. We can change the value of “pref_camera_picturesize_key” node in the xml file programmatically. Then we launch the camera app. At last, we can restore the “picture size” setting.
Be careful! If you only follow these steps, the loaded camera app will not meet the desired effect. Because the camera app maybe can’t realize some settings changed, I think. There is a trick that you can disable and enable the app to take into effect. It’s very probably that the app will re-read the preferences file after the disable and enable operation. I guess the camera app read the settings and always runs in background when the device boots. We can disable and enable an app manually in android.
Of course, we can do this with the “Secure Setting” plugin for Tasker.
As for how to change the setting string in the preferences file, you can use shell script(especially “sed”, “awk” command) or use two files for renaming and swapping.
Here is the flowchart of the whole idea. (I've tried it successfully in MIUI 3.9.6)
9/18/2013
Launch App From Its Name
Long time ago, I want to launch app when AutoVoice recongnized the app name I said. Unfortunately, the "Launch App" will not support app name as variable at present. After some digging, I found a way out. Here it is.
A launcher is something similar with desktop shell in Windows, I think. You should know most app will leave its package information in the database of launcher when installed. So we can dive into the database of launcher and pull the specific information out. The figures below shows the database of MIUI launcher in my MIUI ROM. You can find the database in path /data/data/com.miui.home/databases/launcher.db.
In "Figure 3", the field "intent" is very important for us. We can launch app with "am start" command in Android shell. You can type "am start" command in shell to get detailed help of this command.
We can launch specific app with "am start" command when we extract useful intent information from corresponding "intent" field.
Here is one of my AutoVoice task which aimed to launch app from speech:
Task: LaunchApp
A1: Run Shell [ Command:sqlite3 /data/data/com.miui.home/databases/launcher.db "SELECT intent FROM favorites WHERE intent IS NOT NULL AND title LIKE '%%avcommnofilter%' LIMIT 1;" Timeout (Seconds):0 Use Root:On Store Output In:%intent Store Errors In: Store Result In: ]
A2: If [ %intent Is Set ]
A3: Variable Search Replace [ Variable:%intent Search:#Intent;action= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:am start -a ]
A4: Variable Search Replace [ Variable:%intent Search:;category= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -c ]
A5: Variable Search Replace [ Variable:%intent Search:;launchFlags= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -f ]
A6: Variable Search Replace [ Variable:%intent Search:;component= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -n ]
A7: Variable Search Replace [ Variable:%intent Search:;end Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Run Shell [ Command:%intent Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
A9: Else
A10: Music Play [ File:Tasker/Notify/Dialog/sorry.wav Start:0 Loop:Off Stream:3 ]
A11: End If
Note:
1. Records are case-sensitive in SQLite database. My former task can not process this situation.
2. Few apps can't show on desktopof launcher, and even can't be found in launcher.db. You can't launch it in this way.
3. Although I talked here with taking the MIUI launcher as example, I think the principle will be same with other launcher. Maybe databases differ!
4. If you want do it with a separate app, you can try AutoLaunch(paid).
5. Some useful files for all packages installed: /data/system/packages.list /data/system/packages.xml
6. A useful command to list packages: "pm list packages -f"
A launcher is something similar with desktop shell in Windows, I think. You should know most app will leave its package information in the database of launcher when installed. So we can dive into the database of launcher and pull the specific information out. The figures below shows the database of MIUI launcher in my MIUI ROM. You can find the database in path /data/data/com.miui.home/databases/launcher.db.
Figure 1. tables in launcher.db
Figure 2. records in the table "favourites"
Figure 3. record of app named "SwipePad"
In "Figure 3", the field "intent" is very important for us. We can launch app with "am start" command in Android shell. You can type "am start" command in shell to get detailed help of this command.
Figure 5. "am start" command help
We can launch specific app with "am start" command when we extract useful intent information from corresponding "intent" field.
Here is one of my AutoVoice task which aimed to launch app from speech:
Task: LaunchApp
A1: Run Shell [ Command:sqlite3 /data/data/com.miui.home/databases/launcher.db "SELECT intent FROM favorites WHERE intent IS NOT NULL AND title LIKE '%%avcommnofilter%' LIMIT 1;" Timeout (Seconds):0 Use Root:On Store Output In:%intent Store Errors In: Store Result In: ]
A2: If [ %intent Is Set ]
A3: Variable Search Replace [ Variable:%intent Search:#Intent;action= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:am start -a ]
A4: Variable Search Replace [ Variable:%intent Search:;category= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -c ]
A5: Variable Search Replace [ Variable:%intent Search:;launchFlags= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -f ]
A6: Variable Search Replace [ Variable:%intent Search:;component= Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: -n ]
A7: Variable Search Replace [ Variable:%intent Search:;end Ignore Case:On Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A8: Run Shell [ Command:%intent Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
A9: Else
A10: Music Play [ File:Tasker/Notify/Dialog/sorry.wav Start:0 Loop:Off Stream:3 ]
A11: End If
Note:
1. Records are case-sensitive in SQLite database. My former task can not process this situation.
2. Few apps can't show on desktopof launcher, and even can't be found in launcher.db. You can't launch it in this way.
3. Although I talked here with taking the MIUI launcher as example, I think the principle will be same with other launcher. Maybe databases differ!
4. If you want do it with a separate app, you can try AutoLaunch(paid).
5. Some useful files for all packages installed: /data/system/packages.list /data/system/packages.xml
6. A useful command to list packages: "pm list packages -f"
9/16/2013
Useful Links About Tasker
Blogroll:
Pocketables: http://www.pocketables.com/2013/03/overview-of-pocketables-tasker-articles.html
Tasker Fantasy: http://taskerfans.blogspot.com/
Benny Technology Workroom: http://technologyworkroom.blogspot.com/search/label/Tasker
A More Common Hades: http://a-more-common-hades.blogspot.com/
Tasker for Android - Profile: http://tasker-profiles.blogspot.com/
Almost A Technocrat: http://almost-a-technocrat.blogspot.com/search/label/Tasker
Tasker Valley: http://taskeralley.tk/
I have burned some useful links about Tasker into "Tasker Craft". You can subscribe and read it with RSS reader.
Pocketables: http://www.pocketables.com/2013/03/overview-of-pocketables-tasker-articles.html
Tasker Fantasy: http://taskerfans.blogspot.com/
Benny Technology Workroom: http://technologyworkroom.blogspot.com/search/label/Tasker
A More Common Hades: http://a-more-common-hades.blogspot.com/
Tasker for Android - Profile: http://tasker-profiles.blogspot.com/
Almost A Technocrat: http://almost-a-technocrat.blogspot.com/search/label/Tasker
Tasker Valley: http://taskeralley.tk/
I have burned some useful links about Tasker into "Tasker Craft". You can subscribe and read it with RSS reader.
9/10/2013
How To Set Default App for Various Categories via Tasker
Sometimes we want to set default application for some certain actions.(Just like building associations) Following figure shows the dialog of setting default app for audio player.
You can use Default App Manager or change the setting manually.(refer here for more information)
Following figures show the UI of Default App Manager.
Recently I came up with an idea about how to set default app for various categories via Tasker.
After looking up information and doing several tests, I can make it through now. Hereinafter I will show you how. Note that you can't set default app in the background silently in Android.
You can callout the dialog of setting default app for various categories after sending specific intent parameters to com.android.internal.app.ResolverActivity. Intents are messages of android applications somehow. You can send intents via the “Send Intent” action directly or “Run Shell” action with specific commands. I suggest you’d better use the “Run Shell” action, because some intents may need some specific limits of authority.(Don’t forget “Run Shell” action have option of using root while “Send Intent” just act as usual) Here we go!
<app.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.apk" -t "application/vnd.android.package-archive" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<audio.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.mp3" -t "audio/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<audiostream.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "http:///null.mp3" -t "audio/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<video.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.mp4" -t "video/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<videostream.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "http:///null.mp4" -t "video/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<image.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.jpg" -t "image/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<image.GetContent.Resolver>
Run Shell [ Command:am start -a android.intent.action.GET_CONTENT -d "file:///null.jpg" -t "image/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<image.Crop.Resolver>
Run Shell [ Command:am start -a com.android.camera.action.CROP -d "file:///null.jpg" -t "image/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<browser.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "http://null.com" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<calender.Edit.Resolver>
Run Shell [ Command:am start -a android.intent.action.EDIT -t "vnd.android.cursor.item/event" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<email.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "mailto:" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<epub.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.epub" -t "application/epub+zip" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<mobi.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.mobi" -t "application/x-mobipocket-ebook" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<doc.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.doc" -t "application/msword" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<docx.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.docx" -t "application/vnd.openxmlformats-officedocument.wordprocessingml.document" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<ppt.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.ppt" -t "application/vnd.ms-powerpoint" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<pptx.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.pptx" -t "application/vnd.openxmlformats-officedocument.presentationml.presentation" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<xls.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.xls" -t "application/vnd.ms-excel" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<xlsx.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.xlsx" -t "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<pdf.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.pdf" -t "application/pdf" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<txt.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.txt" -t "text/plain" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<launcher.Main.Resolver>
Send Intent [ Action:android.intent.action.MAIN Cat:Home Mime Type: Data: Extra: Extra: Package:android Class:com.android.internal.app.ResolverActivity Target:Activity ]
You can make a scene to list every one of the “resolver” task above showing as an icon. Every icon is bind to specific task to perform. Then you can set default app for specific categories when the correspondent icon is taped.
Following figure shows a simple UI of my creation.
Note:
1. AFAIK, you can’t retrieve the default app name for specific categories via Tasker.
You can use Default App Manager or change the setting manually.(refer here for more information)
Following figures show the UI of Default App Manager.
Recently I came up with an idea about how to set default app for various categories via Tasker.
After looking up information and doing several tests, I can make it through now. Hereinafter I will show you how. Note that you can't set default app in the background silently in Android.
You can callout the dialog of setting default app for various categories after sending specific intent parameters to com.android.internal.app.ResolverActivity. Intents are messages of android applications somehow. You can send intents via the “Send Intent” action directly or “Run Shell” action with specific commands. I suggest you’d better use the “Run Shell” action, because some intents may need some specific limits of authority.(Don’t forget “Run Shell” action have option of using root while “Send Intent” just act as usual) Here we go!
<app.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.apk" -t "application/vnd.android.package-archive" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<audio.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.mp3" -t "audio/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<audiostream.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "http:///null.mp3" -t "audio/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<video.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.mp4" -t "video/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<videostream.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "http:///null.mp4" -t "video/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<image.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.jpg" -t "image/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<image.GetContent.Resolver>
Run Shell [ Command:am start -a android.intent.action.GET_CONTENT -d "file:///null.jpg" -t "image/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<image.Crop.Resolver>
Run Shell [ Command:am start -a com.android.camera.action.CROP -d "file:///null.jpg" -t "image/*" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<browser.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "http://null.com" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<calender.Edit.Resolver>
Run Shell [ Command:am start -a android.intent.action.EDIT -t "vnd.android.cursor.item/event" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<email.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "mailto:" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<epub.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.epub" -t "application/epub+zip" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<mobi.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.mobi" -t "application/x-mobipocket-ebook" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<doc.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.doc" -t "application/msword" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<docx.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.docx" -t "application/vnd.openxmlformats-officedocument.wordprocessingml.document" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<ppt.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.ppt" -t "application/vnd.ms-powerpoint" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<pptx.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.pptx" -t "application/vnd.openxmlformats-officedocument.presentationml.presentation" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<xls.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.xls" -t "application/vnd.ms-excel" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<xlsx.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.xlsx" -t "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<pdf.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.pdf" -t "application/pdf" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<txt.View.Resolver>
Run Shell [ Command:am start -a android.intent.action.VIEW -d "file:///null.txt" -t "text/plain" -n "android/com.android.internal.app.ResolverActivity" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ]
<launcher.Main.Resolver>
Send Intent [ Action:android.intent.action.MAIN Cat:Home Mime Type: Data: Extra: Extra: Package:android Class:com.android.internal.app.ResolverActivity Target:Activity ]
You can make a scene to list every one of the “resolver” task above showing as an icon. Every icon is bind to specific task to perform. Then you can set default app for specific categories when the correspondent icon is taped.
Following figure shows a simple UI of my creation.
Note:
1. AFAIK, you can’t retrieve the default app name for specific categories via Tasker.
2. You can try this tip, if you want to "Control which app is the default for an action (root only)".
9/09/2013
Custom the display of Operator name via Tasker
The figure following show the custom operator of mine:
The setting UI for custom operator name:
Hereinafter I will show you how to custom the display of operator name via Tasker.
I found the system save the operator name in /data/data/com.android.providers.settings/databases/settings.db
The system table of Setting.db contains operator name-value pairs(records, its professional name). We need to change the value of specific SIM operator.
Note that table may have more than one records whose name with “MOBILE_OPERATOR_NAME_” prefix. Trial and error, I found the numbers which following “MOBILE_OPERATOR_NAME_”, mean the MCC+MNC part of IMSI. In China, 46001 means China Unicom, While 46000, 46002,46007 mean China Mobile Communication(CMCC for short).
But how can Tasker judge the SIM inserted represent which operator? Firstly, you may think of specific part of phone number. But here I will tell you that Android saystem can’t get the exact phone number for some new SIM card unfortunately. I got nothing with my SIM card of CMCC when I try to use the built-in variable %PNUM.
Things seem to be stuck for a time. Finally the problem was solved when I know the first 6 characters of SIM numbers(refer to ICCID) differ from operators internationally. ASAIK, 898600 was assigned to CMCC while 898601 was assigned to China Unicom. So I get my ideas into shape finally.
Tips: You can set special characters or symbols as personalized operator name. A simple way is to use special symbols in Input Method.
Step 10: For [ Variable:%spn Items:%spn_list() ]
Step 12: End For
The setting UI for custom operator name:
Hereinafter I will show you how to custom the display of operator name via Tasker.
I found the system save the operator name in /data/data/com.android.providers.settings/databases/settings.db
The system table of Setting.db contains operator name-value pairs(records, its professional name). We need to change the value of specific SIM operator.
Note that table may have more than one records whose name with “MOBILE_OPERATOR_NAME_” prefix. Trial and error, I found the numbers which following “MOBILE_OPERATOR_NAME_”, mean the MCC+MNC part of IMSI. In China, 46001 means China Unicom, While 46000, 46002,46007 mean China Mobile Communication(CMCC for short).
But how can Tasker judge the SIM inserted represent which operator? Firstly, you may think of specific part of phone number. But here I will tell you that Android saystem can’t get the exact phone number for some new SIM card unfortunately. I got nothing with my SIM card of CMCC when I try to use the built-in variable %PNUM.
Things seem to be stuck for a time. Finally the problem was solved when I know the first 6 characters of SIM numbers(refer to ICCID) differ from operators internationally. ASAIK, 898600 was assigned to CMCC while 898601 was assigned to China Unicom. So I get my ideas into shape finally.
Tips: You can set special characters or symbols as personalized operator name. A simple way is to use special symbols in Input Method.
As for detailed steps, you can see below.
Step
1: Variable Clear [ Name:%Runcmd Pattern Matching:Off ]
Clear the query variable
Step
2: Variable Query [ Title: Please Input Custom Operator Name: Variable:%Runcmd
Input Type:Normal Text Default: Background Image: Layout:scene_VarQuery Timeout
(Seconds):40 Show Over Keyguard:On ]
Step
3: Stop [ With Error:Off Task: ] If [ %Runcmd ! Set ]
Step
4: Variable Set [ Name:%sim To:%SIMNUM Do Maths:Off Append:Off ]
Step
5: Variable Section [ Name:%sim From:1 Length:6 Adapt To Fit:Off Store Result
In:%sim ]
<CMCC>
Step
6: Variable Set [ Name:%spn_list To:46000,46002,46007 Do Maths:Off Append:Off ] If [ %sim = 898600 ]
<China Unicom>
Step
7: Variable Set [ Name:%spn_list To:46001 Do Maths:Off Append:Off ] If [ %sim = 898601 ]
Step
8: Variable Split [ Name:%spn_list Splitter:, Delete Base:Off ]
Step 9: Airplane Mode [ Set:On ]
Step 9: Airplane Mode [ Set:On ]
Step 10: For [ Variable:%spn Items:%spn_list() ]
<only
change specific SIM operator name>
Step 11: Run Shell [ Command:sqlite3
/data/data/com.android.providers.settings/databases/settings.db "update
system set value='%Runcmd' where name='MOBILE_OPERATOR_NAME_%spn'" Timeout
(Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In:
Continue Task After Error:On ]
Step 12: End For
<change
all SIM operator name>
Step
13: [X] Run Shell [ Command:sqlite3
/data/data/com.android.providers.settings/databases/settings.db "update
system set value='%Runcmd' where name like 'MOBILE_OPERATOR_NAME_%'"
Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result
In: Continue Task After Error:On ]
Step
14: Airplane Mode [ Set:Off ]
Note: If you want to change current SIM operator in China, use step 1-2,14. Well, if you want change all SIM operator name in China, use step 1-3,9,13,14.
9/08/2013
Retrieve SD Card Mounted Path
Sometimes we want to set/get the external storage root path as global variable in Tasker, no matter which ROM we flash or update. Next time when you want to use file path in SD card, just use variable %MNT_SD as path prefix.
You can do it like this:
Profile:(Device Boot)
Context: "Event -> Device Boot"
Task: 1. "Wait[5 seconds]";
/*wait 5 seconds to let system initialize some settings*/
2. "Run Shell(use root)
[Command: cat /system/etc/vold.fstab | busybox grep "sdcard" | busybox awk '{printf $3}'
Use Root: check;
Store Output In: %MNT_SD ]"
"Run Shell" action configure:
vold.fstab file in MIUI(/system/etc/):
Note: I had test it on my MiOneS phone(MIUI ROM). More info about vold.fstab file, please refer here.
9/05/2013
Tools or Language To Develop Applications On Android
Many people want to develop apps on Android for certain reason. There are some tools at their choice. Here is a part of list.
Java
As everyone knows, a lot of apps are developed by using Java language. You can find numerous resource about it.
App Inventor
A visual development environment for developing simple application on Android. It is published at about 2010. At about 2011, Google distribute the project to MIT. So it's a online product of MIT now. You can find it here.
Tasker AppFactory
Through the awesome app - Tasker, you can make some powerful creations. Then you can package and export your creation as an app. You can get it from Google Play.
SL4A
Kivy + Python
A brief experience of Kivy + Paython on Android, here you go.
Java
As everyone knows, a lot of apps are developed by using Java language. You can find numerous resource about it.
App Inventor
A visual development environment for developing simple application on Android. It is published at about 2010. At about 2011, Google distribute the project to MIT. So it's a online product of MIT now. You can find it here.
Tasker AppFactory
Through the awesome app - Tasker, you can make some powerful creations. Then you can package and export your creation as an app. You can get it from Google Play.
SL4A
Scripting Layer for Android (SL4A) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface that makes it easy to get things done.Visit SL4A homepage>>
Kivy + Python
Visit Kivy homepage>>Kivy - Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.
A brief experience of Kivy + Paython on Android, here you go.
Labels:
Android,
AppFactory,
AppInventor,
develop,
Kivy,
SL4A,
Tasker
Subscribe to:
Posts (Atom)



































