Google Chrome User Agent Android 7.x - Android Q&A, Help & Troubleshooting

Hi,
how can i Set Chrome User Agent to Desktop or chromebook on Android 7.x ?
Old User Agent Apps won't work on 7.x
I need to Set Chrome to Desktop view always on

Put a file in Data/Local called 'chrome-command-line', put this text in
chrome --user-agent="Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36" -force-device-scale-factor=2
Permissions 644, you can change the scale-factor to suit.

Sorry but this is Not working anymore on 7.x

Nobody ?

Just wanted to bump this as I'm also looking for a solution.

This has been bugging me for for a few days, very frustrating, seems like Chrome doesn't read the command line files in Nougat no matter where they are located, what they are called, or how you invoke the application. So I did the next best thing...
I grabbed the latest Chromium source code and modified user_agent.cc so it spits out a desktop UA instead. Cross compiling was a bit of a lengthy process, around 4 hours, but it works perfectly. The code alteration was quite trivial, I know this doesn't really help anyone here with a quick fix, and I really can't see Google adding a permanent desktop mode any time ever.
To make the change, just edit the following and rebuild:
<path>/src/content/common/user_agent.cc
PHP:
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
const std::string& product) {
// Derived from Safari's UA string.
// This is done to expose our product name in a manner that is maximally
// compatible with Safari, we hope!!
std::string user_agent;
// base::StringAppendF(
// &user_agent,
// "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
// os_info.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR,
// product.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR);
// return user_agent;
return "<Insert desired user agent here>";
}

dtchky said:
This has been bugging me for for a few days, very frustrating, seems like Chrome doesn't read the command line files in Nougat no matter where they are located, what they are called, or how you invoke the application. So I did the next best thing...
I grabbed the latest Chromium source code and modified user_agent.cc so it spits out a desktop UA instead. Cross compiling was a bit of a lengthy process, around 4 hours, but it works perfectly. The code alteration was quite trivial, I know this doesn't really help anyone here with a quick fix, and I really can't see Google adding a permanent desktop mode any time ever.
To make the change, just edit the following and rebuild:
<path>/src/content/common/user_agent.cc
PHP:
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
const std::string& product) {
// Derived from Safari's UA string.
// This is done to expose our product name in a manner that is maximally
// compatible with Safari, we hope!!
std::string user_agent;
// base::StringAppendF(
// &user_agent,
// "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
// os_info.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR,
// product.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR);
// return user_agent;
return "<Insert desired user agent here>";
}
Click to expand...
Click to collapse
Would it be possible for you to share the apk? This is frustrating me beyond belief after I moved to Nougat.

Found a solution for this problem, it was caused by a SELinux context which blocked read access to the command line file.
Download this script and copy it on the SDCard.
Install Android Terminal Emulator, then enter:
Code:
su
sh /sdcard/chrome.sh

- Testing 7.x fix. https://play.google.com/store/apps/details?id=com.linuxjet.apps.ChromeUA

jpeterson said:
- Testing 7.x fix. https://play.google.com/store/apps/details?id=com.linuxjet.apps.ChromeUA
Click to expand...
Click to collapse
Thank you. Is this working for anyone?

cobram3 said:
Thank you. Is this working for anyone?
Click to expand...
Click to collapse
It is available on the play store. I can not guarantee this will work, but I have tested it on my 7.x devices and 8.x devices and it is working on them.

Does not work on my OnePlus 5T on Android 8.0 rooted with Magisk.
Neither does the script posted above.
Any other ideas? I'm sick of manually selecting "view non crippled site" every time I open any webpage.
"Mobile" sites need to die!
EDIT: I figured it out, I needed to set the /data/local directory to be readable by all. (The script above already got the file permissions right for the chrome-command-line file, just not the directory it lived in). After that the user agent string seems to be working as it should and I can actually view useful webpages again!

Well, so much for that.
I wiped my phone and started over, and the same steps I used last time have no effect this time. I'm stuck in mobile website hell.
Anyone with any idea how to fix this?
EDIT: This seems to be related to the file permissions issue still, but I'm not sure how to fix it. When I'm not root, I get permission denied when I do an ls on the /data/local directory, despite that directory, and all the ones above it, being set 755. So whatever is blocking me from being able to ls that directory is also likely blocking the ability for chrome to read that file and behave like a useful web browser instead of a completely crippled one.

ve6rah said:
Does not work on my OnePlus 5T on Android 8.0 rooted with Magisk.
Neither does the script posted above.
Any other ideas? I'm sick of manually selecting "view non crippled site" every time I open any webpage.
"Mobile" sites need to die!
EDIT: I figured it out, I needed to set the /data/local directory to be readable by all. (The script above already got the file permissions right for the chrome-command-line file, just not the directory it lived in). After that the user agent string seems to be working as it should and I can actually view useful webpages again!
Click to expand...
Click to collapse
You can create a "chrome desktop"widget with that app,only by this way,it seems to work.

Unfortunately that only works for opening the browser and does nothing for links clicked in our applications.
Why do developers of websites hate mobile users? This isn't 1998 anymore, people want to access websites from their phones! We shouldn't have to resort to such ridiculous lengths to enable such basic functionality as a working web browser!

https://forum.xda-developers.com/showthread.php?t=1811101&page=13 #128

That helps quite a bit.
Now of course I've run in to another problem. AMP. google assistant and related products love to push AMP pages instead of websites, and chrome won't open them in desktop mode, only in mobile mode. I wonder if there's some way to convince Google assistant to behave and link to real webpages?
*sigh* it's amazing how far companies are willing to go to cripple their websites!
EDIT: Found it! DeAMPify in the play store translates all those external programs (like the google feed) to non amp versions before passing them to the browser.
With enough steps and work-arounds you too can have a functioning web-browser on your smartphone!

I'm here to confirm Wootever's script working on [ROM][8.1.0][STABLE][OFFICIAL][TREBLE] AospExtended ROM V5.4 [Z2 PRO]. I had already created the chrome-command-line file via file explorer and set permissions to 755, but it wasn't working. Customized the UA string to my liking, btw (X11; Linux Arm64).
The way G00gl€ is developing Chrome is fLIck1ng annoying, this is basic functionality being set aside because fLIck you. Latest Android Chrome versions (63 to 66) are a piece of sh1t imho.
Cheers

Wootever said:
Found a solution for this problem, it was caused by a SELinux context which blocked read access to the command line file.
Download this script and copy it on the SDCard.
Install Android Terminal Emulator, then enter:
Code:
su
sh /sdcard/chrome.sh
Click to expand...
Click to collapse
Does anyone still have this file?

Reupload
Reupload ulozto.sk/file/R55e4UbG3ppA/chrome-sh

Related

StartOperaMini: Mortscript for *easily* launching and controlling Opera Mini!

10/20/2008: You may or may not notice that I haven't updated the script in a while. I had lost my windows mobile phone (t-mobile shadow) many months ago and I guess that killed my enthusiasm and any practical way to do testing (process detection doesn't work very well on the emulator). It also doesn't help that mortscript is frozen in time as well. Since I don't really see many Windows Mobile Standard devices coming out and I refuse to use a phone that requires a stylus, my next phone will likely be an android device (which interestingly enough, has an opera mini port).
There are probably a few bugs lurking around in the code for some fringe cases, but as always, you are welcomed to examine and update the script to your needs and it would be very appreciated if you would post a link to the update here. Also, I think JZ's SmartMort script is still keeping things interesting so you may want to check that out.
Click to expand...
Click to collapse
Latest version: 06/17/2008 0.11b
Faster Startup, Better OM control, Select / Copy / Paste (works in smartphone MS Word!), HotKey, and many fixes.
Click to expand...
Click to collapse
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
INTRODUCTION
You probably know of Menneisyys' original thread of making Opera Mini behave like the default browser by responding to links in emails and other locations. A component of making that work is a script to launch opera mini and enter the url. I've been enhancing my version of the script to make it easy to everyone to use.
While this script has some powerful options, its main purpose is to make it easy to launch opera mini directly and use opera mini to handle links.
At first run, an auto-detection process will try to automatically figure out how to launch opera mini and update your device so links are opened by Opera Mini. No more worrying about what jbed.exe parameters to use. Launching the script directly will open Opera Mini so you can just reference the script in shortcuts and launchers.
In previous versions of the script, you had to manually guess how much delay is needed before opera mini is ready for the script to enter the url. This script has method to detect if Opera Mini is running and if it's ready automatically.
If anything changed on your system that affects Opera Mini, just run Setup to re-detect your settings or tweak a setting. No text editing of the script required.
FEATURES
Make Opera Mini your default browser
When you run the script, the script will automatically find and launch Opera Mini. Optionally, update your registry so links in emails, contacts, appointments, documents, and other apps are handled by Opera Mini. Optionally, create a Start Menu shortcut with icon to launch Opera Mini.
Works with both Opera Mini 3.1, 4.0 and 4.1. Landscape and fullscreen mode is supported. Will work with 4.1 with Auto-complete Address Input enabled or not.
Quickswitch
Invoke the script with OM visible and you can have the script automatically option open the current page in IE and vice versa. This is handy when you encounter a page that would render better in the other browser. For example, in Opera Mini, you encounter a page with a youTube video so you quickswitch to IE to view the video.
Hotkey
You can assign a single hardware button to the HotKey shortcut and have quick access to most script features, including text select, copy, and paste commands.
Customizations / Special features
Enable prompting of what action to take when invoking a link or starting the script, such as asking which browser to use or sending the url to the clipboard. Timeout option available.
Add your own custom applications as choices to respond to links, so you can add browsers like netfront or opera.
Exclude list for sites that you want to automatically open in an alternative app like IE, such as your provider's private-network MMS server. Also good for automatically using IE to download files that Opera Mini may not handle correctly. Prompt and timeout option available.
Patch selector.utf file to eliminate permission prompting by midlets.
Create shortcuts to all your midlets in your Start Menu.
Click to expand...
Click to collapse
HISTORY
11/29/2007 0.01b: Initial version (based on Menneisyys' script) [details]
04/06/2008 0.02b: Next version (based on info from JZ's script) [details]
04/10/2008 0.03b: Enhanced and uploaded to this thread
04/11/2008 0.04b: Fix: will find jbed.exe if even no quotes are around the registry value [details]
04/11/2008 0.05b: landscape support, address input optimizations, improved DAI tolerance, shortcut with icon created, filename change to ini file. [details]
04/12/2008 0.06b: tweaked delay b/t keys and delay after paste [details]
04/15/2008 0.07b: Shortcuts created in localized Start Menu location, Prompt-less auto-configuration, Alternative url input methods, What to do options list, To kill jbed or not, 'Start Opera Mini Setup' [details]
04/22/2008 0.08b: More url paste options, Improved opera control scheme, Shortcuts add/remove options, More Setup functions, selector.utf patching, Reworked logic on when to kill jbed.exe [details]
04/25/2008 0.09b: Exclusion list, Last Link saved, Improved shortcut icons, help file [details]
Update: 04/25/2008 2:50pm EST: found a bug where trim would repeat forever. Fixed and re-uploaded. [details]
05/15/2008 0.10b: Custom Commands, Improved Exclude options, Prompting with timeout, Quickswitch, Special Commands, JVM selection improvements, Fixes [details]
UPDATE1: 05/15/2008 11PM EST 0.10b sp1: found some bugs with quickswitch if Use Direct Address Input is enabled. Fixed and re-uploaded.
UPDATE2: 05/16/2008 12PM EST: 0.10b sp2: got quickswitch working on my WM6 PDA by introducing context-menu methods for copy, paste, and select-all. Of course, only touch-screen devices have a context-menu. Also, you can choose different copy, paste, and select methods for use in OM and IE, which is important since context-menus don't appear to work within my JVM. Also added prompt and prompt timeout options to quickswitch [details]
UPDATE3: 05/20/2008 1:30PM EST: 0.10b sp3: more quickfix tweaks, more commands when using quickswitch prompt so the prompt is more like a context menu allowing to perform an action with the current url or task-switch between browsers. Also added a sample bookmarks.mscr script that you can add to your list of commands and use with quickswitch prompt to have a unified bookmark list between IE and OM. [details]
06/17/2008 0.11b: Faster Startup, Better OM control, Select / Copy / Paste, HotKey, and many fixes. [url="http://forum.xda-developers.com/showthread.php?t=384271&page=14#138][details][/url]
Click to expand...
Click to collapse
TO DO / KNOWN BUGS:
On some platforms, Mortscript will crash if it tries to read the clipboard containing a large amount of text (around 16KB+ on my smartphone). This is easy to do if you are editing a large document and do a select-all + copy. My script will detect the crash and offer to clear the clipboard contents so mortscript will not crash again if you repeat the same action.
When viewing a script dialog window, like a prompt window or a setup window, it is possible for another application come into focus and you will lose access to the script window. A common way this can happen is when you receive a phone call and the call window appears. My script will automatically check if its dialog windows is in focus and if not, it will try to bring it to focus. This usually works but I've seen where the script only manages to get the title bar to appear but the rest of the screen still shows the previous application. User inputs will be focused on the script though you can't visually see the results. If this scenario occurs, just wait a few minutes and mortscript will eventually bring the dialog window back in focus. If you can't wait, you can kill mortscript via HotKey > StopScripts or manually run \sub\stop_scripts.
Click to expand...
Click to collapse
Be sure to download the version you want. I'm keeping some of the previous version up in case of bugs or undesired behavior in the latest version.
REQUIREMENTS
Jbed JVM
Jbed 2.1: (recommended)
http://www.modaco.com/index.php?act=attach&type=post&id=23899
Jbed 3.1:
http://forum.xda-developers.com/showpost.php?p=2127317&postcount=65
Jbed 3.1 has a bug on smartphones where if you switch away from jbed and then switch back, the screen may not refresh. Workaround is to manually start the JVM, select Menu > Background Running, and finaly start Opera Mini. Script setting 'Kill JVM First' will need to be set to 'No'. This is also a good method to allow you to switch away from Opera Mini while it's still loading the page and come back when it's done. This will work for Jbed 2.1 as well.
If you have multiple versions of jbed installed, then the script may not correctly find the version you are using. You can run the Setup application and manually select your JVM executable and the selector.utf file that catalogs the midlets you have installed.
If you start the script to start Opera Mini and briefly see a flash of white, then either the script has chosen the wrong JVM/selector.utf pair or you recently installed a JVM that is of a different version from your last one. In the latter case, your currently installed midlets may not work with the newly installed JVM and you may need to uninstall all your midlets and reinstall them.
Click to expand...
Click to collapse
Opera Mini (3.1, 4.0, 4.1 beta, 4.1 Final)
http://www.operamini.com
To get the signed version of Opera Mini 4.1 Final so you're not prompted for permissions:
On the device, use IE mobile and go to http://mini.opera.com
The version shown is probably 4.1 US English, No signature, which is probably what you don't want so don't download that. If you're fine with the chosen language, skip to step 5. Otherwise, see the next step.
Click Download in another language.
Now a list of all language versions appear so choose one. I prefer to download Opera Mini 4.1 International for foreign language websites.
Click 'If this version fails to install or you would like to install a previous version, please click here.'
Choose the signed version you want.
Click to expand...
Click to collapse
Mortscript (4.1 or higher)
http://www.sto-helit.de/index.php?module=page&entry=ms_overview&action=view
INSTALLATION
Download Mortscript (4.1 and up), Jbed (2.1 preferred), and Opera Mini (signed version preferred) and install them. Make sure you can run Jbed and then run Opera Mini. You should run Opera Mini at least once to get pass all the initial installation and license agreement screens.
Extract the script contents to anywhere on your device. The zip file contents are stored in a \StartOperaMini\ folder so you can just extract that folder like to '\Program Files\Mortscript\StartOperaMini\'.
In version 0.09b and 0.11b, the OperaIcon.dll is updated with better or additional shortcut icons. You may not be able to directly overrwrite the existing OperaIcon.dll file so rename the file to something else like OperaIcon.dll_, and then transfer the new OperaIcon.dll. A reboot may be needed before the old OperaIcon.dll can be deleted.
To support the new icons, the shortcuts have been modified, so you may need to update your shortcuts from the correct ones in the script folder or run Setup and toggle the Start Menu shortcut option to No and then back to Yes.
Also, you may be asked for permissions to load OperaIcon.dll when you access your Start Menu and the OS tries to load the icon graphics. Just allow it and the message shouldn't appear again.
Click to expand...
Click to collapse
Open file manager, navigate to where you copied StartOperaMini to, and run StartOperaMini.mscr. If this is the first time you're running the script from the current location, then the script will initialize by detecting your JVM and Opera Mini settings and ask you some initial setup questions.
One important question is if you want to register the script so the script is run when you click on a link in emails, documents, etc. This step is optional, but is helpful in making Opera Mini behave like the default browser. If you skip this step but have another version of the script installed elsewhere that is registered, then clicking an email link will open up the other version of the script.
When Opera Mini opens up, installation is complete. Note that version 0.11b does not support the settings from previous versions so you may need to revise the initial settings.
If you want to run the script from an application launcher, either link to the 'Start Opera Mini' shortcut or link directly to the StartOperaMini.mscr script.
If you want to use the HotKey feature to easily access other script commands like copy/paste, you should map a hardware key to the shortcut 'Start Opera Mini Hotkey' and then customize the HotKey function in Setup. View the help file if you need more information.
If you need to change any settings, just run the shortcut 'Start Opera Mini Setup'. View the help file if you need more information.
LIMITATIONS
When opening links to local files or to sites on private carrier networks (portals, MMS server), Opera Mini will fail to get to that address. Run setup and add the host to the exclude list of those links will open in IE instead.
If Internet Explorer is opened, links in contacts and appointments may automatically still use Internet Explorer. Workaround is to kill Internet Explorer first, which is an option in the Setup program.
Some paste and control methods may not work on certain devices, so try different settings in Setup.
UNINSTALLATION
Run the Setup Program and then select the Uninstall option.
Delete script files from the script folder. You may not be able to directly delete the OperaIcon.dll file since the system may still be using it to display the shortcut icon. Rename the file to something else like OperaIcon.dll_, reboot, and then it should be deletable.
THANKS
Much thanks to Menneisyys for giving birth to this breakthrough idea and for JZ SmartMort for bringing new innovations to the table (check out his JZ SmartMort tool). Much ideas and help is from the community so it's really due to everyone's efforts.
Feel free to enhance the script to your own needs and use it in your own projects.
Click to expand...
Click to collapse
[reserved for future use 2]
Hi badbob.
I kind of like the script that you made way back when (Nov.?) that opens up a popup that lets you choose between PIE and OM and the clipboard. It also works for 4.1. It would be neat if the installation script allowed that as an option, and also detected Opera Mobile (and skyfire in the future) and would allow that as an option. Having said that dont make these additions for me as I am happy running the old script. Just thought id give you a suggestion.
Great script..does what it's supposed to and does it well....do you have any issues with it being included with a rom?
Thanks for the script; nice little workaround using the color of the upperleftmost pixel. One thing I've noticed is that I have direct address input turned off in my Opera Mini 4.1. However, I must check "Yes" when asked if it's turned on. Only then will it work properly. Don't know if I'm just reading wrongly, but other than that, it's working perfectly.
By the way I'm using the JBed_20071119.3.1_3dMod_HeapSizeFix_v2_wm6(lovetz1) cab.
It found my jbed.exe, even though it's in a "Jbed3dmod" folder on my storage card.
Overall, it's working great now that I marked off "Yes". Thanks!
famewolf said:
Great script..does what it's supposed to and does it well....do you have any issues with it being included with a rom?
Click to expand...
Click to collapse
No problems. Go ahead.
Replaced
Code:
jbed_exe_ini = Part(RegRead("HKCR","jarfile\Shell\Open\Command",""),"""",2,1)
with
Code:
jbed_exe_ini = replace(RegRead("HKCR","jarfile\Shell\Open\Command",""),"""","")
jbed_exe_ini = SubStr(jbed_exe_ini, 1, find(jbed_exe_ini, "jbed.exe")+7)
So finding the location of jbed.exe from the registry doesn't depend on the quotes being around the command.
Azimuth21 said:
One thing I've noticed is that I have direct address input turned off in my Opera Mini 4.1. However, I must check "Yes" when asked if it's turned on. Only then will it work properly.
Click to expand...
Click to collapse
When you have direct address input (DAI) turned off in both OM and the script, at what point does the script fail?
The following two block of instructions is what the script does when it thinks DAI is turned off.
Code:
LeftSoftKey [open menu]
LeftSoftKey [select Enter Address]
Code:
[select all text]
[paste url over selection]
LeftSoftKey [click OK]
By just being lucky, leaving the script with direct address input turned on will perfectly work even if OM has it turned off. It's just that the extra keys sent don't cause any problems. In your working scenario, having the script think DAI is on will essentially put an extra 'enter' after the first instruction block and then another 'enter' after the second block. Which 'enter' is the one helping you?
volwrath said:
Hi badbob.
I kind of like the script that you made way back when (Nov.?) that opens up a popup that lets you choose between PIE and OM and the clipboard. It also works for 4.1. It would be neat if the installation script allowed that as an option, and also detected Opera Mobile (and skyfire in the future) and would allow that as an option. Having said that dont make these additions for me as I am happy running the old script. Just thought id give you a suggestion.
Click to expand...
Click to collapse
It's relatively easy to slap on the menu option to my script, which tmknight did here.
I'm sure many "power" users will want total control and it's pretty easy to make a script that defers the decisions to the user. But I wanted to try a script that is a bit more friendly and tries to handle decisions on its own... a script that I won't be afraid to put on my wife's phone. Easy is hard.
badbob001 said:
When you have direct address input (DAI) turned off in both OM and the script, at what point does the script fail?
Click to expand...
Click to collapse
badbob001 said:
By just being lucky, leaving the script with direct address input turned on will perfectly work even if OM has it turned off. It's just that the extra keys sent don't cause any problems. In your working scenario, having the script think DAI is on will essentially put an extra 'enter' after the first instruction block and then another 'enter' after the second block. Which 'enter' is the one helping you?
Click to expand...
Click to collapse
Sorry, forgot to clarify. I believe the first enter is helping me, because: if I choose the "No, DAI is Off" option, the script will open up Opera Mini, and stay at the main screen for a few seconds. Still on the OM main screen, the script will say something like "The input box was not found after _ seconds", then ask if I want to go through setup again. If I choose the "Yes, DAI is On" option, everything works normally. Opera Mini opens, the input field is opened, the link is pasted into the input field, the page loads, etc.
Thanks for sharing but on my xda is a german software running called "DK - OperaMini4 Addon" with mortscript 4.1 that does the same as yours. and its out since months. so where are the big news? the only better thing seems to be the autodetecting when mortscript starts running, but you write that this don` t work in mini Landscape mode. but everyone i know uses this mode.
04/11/2008 0.05b
- (Opera's built-in) Landscape support:
I now test pixels in the upper left (0,0)and upper right (screenwidth()-1,0) to determine when Opera is running and what orientation it is. I'm not too sure how consistent the upper right pixels are on different devices, but it works fine on my wm6 standard qvga phone. Knowing the orientation is important since in landscape, you have to now press left or right instead of up and down to open the address bar drop down.
- Slightly improved address input:
The script originally sent [leftsoftkey] to open the opera menu and another [leftsoftkey] to select the 'enter address' option. Since I restart Opera Mini if an url needs to be pasted, the initial cursor is already on the address input box, so I just need to send one [enter].
At least on my device, if Direct Address Input (DAI) is on, a rare case occurs where I need to send an extra [enter] to have Opera submit the url. It doesn't appear to cause any ill effects if two [enter]s are sent every time when using DAI.
- Improved tolerance of mismatch DAI setting:
Some people may notice that if you have DAI (Direct Address Input) disabled in Opera but enabled in the script, the extra keys sent by the script don't cause any problems except for being a micro-fraction slower.
For the opposite scenario where if you have DAI enabled in Opera but disabled in the script, the previous result was that the script will complain that it didn't find the Address Input window. Now when it doesn't find the Address Input window, it will assume DAI is really turned on and send the extra DAI keys. If that doesn't work, then you it will complain. But if does, it'll continue with no problems. The *next* time you run the Opera Mini, the script will say that it thinks you told it the wrong DAI setting and offers to run the setup wizard for you to enter the correct settings.
- Start Menu Shortcut with icon
The setup wizard will add a 'Start Opera Mini' shortcut to your Start Menu and it will have the Opera icon:
Kevxross here: http://forum.ppcgeeks.com/showthread.php?t=7346 embedded the opera icon in a dll so it can be referenced by shortcuts. I've included the .dll in the .zip, so just copy it to the same location as the script.
- Ini file renamed
The only manual step that users may need to do is delete the .ini file if they want to easily get the setup wizard to run again. But I noticed that the built-in file manager will hide the extension of files and so users can't really tell the ini file from the script. I've renamed the ini file to <scriptname>_ini.txt. If you're upgrading, the script will automatically rename the existing .ini to _ini.txt.
badbob001 said:
It's relatively easy to slap on the menu option to my script, which tmknight did here.
I'm sure many "power" users will want total control and it's pretty easy to make a script that defers the decisions to the user. But I wanted to try a script that is a bit more friendly and tries to handle decisions on its own... a script that I won't be afraid to put on my wife's phone. Easy is hard.
Click to expand...
Click to collapse
Heh I understand completely. I was able to successfully modify your previous script, so its good by me
here`s the link to the software that does work like yours[/B]. This is out for 2 or 3 months but your welcome to develope the same twice::
Makes as direct shortcut to Opera mini including opera icon and opens urls with mortscript 4.1 ("Opera Mini addon direkt"):
http://www.ppc-welt.info/community/showthread.php?t=122764
Is there a version of this script for smartphone? It works great for PPC, but copy and paste doesn't exist on WM 6.0 standard and fails on my BlackJack II.
bluemetalaxe said:
here`s the link to the software that does work like yours[/B]. This is out for 2 or 3 months but your welcome to develope the same twice::
Makes as direct shortcut to Opera mini including opera icon and opens urls with mortscript 4.1 ("Opera Mini addon direkt"):
http://www.ppc-welt.info/community/showthread.php?t=122764
Click to expand...
Click to collapse
We are so happy you found a similar script months ago. You've posted about it twice now within 6 posts of each other. Please stop harassing the author of this one as several of us are quite happy with his script. Does the old script still use wait states? The new one doesn't. Does the old one automatically find your jbed even if it's on a storage card and find the slot opera is installed in no matter which one you used? The new one does. Finally his current version works with landscape. The entire page you referenced is in a foreign language and I for one appreciate support from an author who can communicate without the need to use babelfish.
Extra carriage return?
Hi badbob and all.
Thanks to everyone who contributed to this script. I'm lovin this.
I'm running Opera Mini 4.1 (v. 4.1.10781, 20080401 to be exact) on a Sprint Mogul / HTC Titan. After installation and first-time setup the script correctly launched OM and pasted in the link. However the page did not load. I had to manually hit the enter key to make it start the loading process.
After poking around in the script for a while I managed to make it load automatically. Around line 320 in the StartOM subroutine I added a wait between the two sendcr commands.
Code:
if ((opera_version_ini eq "4.1" AND direct_address_input eq True) OR (tried_again = True))
sendcr
[B]sleep(wait_time_between_keys)[/B]
sendcr
endif
I don't know whether I fixed a script bug or my phone just has special needs.
Great work i was thinking of the same thing today.
Thanks alot.
cheesiest said:
Hi badbob and all.
Thanks to everyone who contributed to this script. I'm lovin this.
I'm running Opera Mini 4.1 (v. 4.1.10781, 20080401 to be exact) on a Sprint Mogul / HTC Titan. After installation and first-time setup the script correctly launched OM and pasted in the link. However the page did not load. I had to manually hit the enter key to make it start the loading process.
After poking around in the script for a while I managed to make it load automatically. Around line 320 in the StartOM subroutine I added a wait between the two sendcr commands.
Code:
if ((opera_version_ini eq "4.1" AND direct_address_input eq True) OR (tried_again = True))
sendcr
[B]sleep(wait_time_between_keys)[/B]
sendcr
endif
I don't know whether I fixed a script bug or my phone just has special needs.
Click to expand...
Click to collapse
I'm not quite sure how to classify this issue. My code originally only had one sendcr in that section. Then on the rare occasion, I'll see the pasted url in the address field waiting for me to hit enter to submit it. I do notice that everytime I see this happen, the last character in the pasted url is a square box, which means a character the device can't display. I figured, what the hey, lets add another sendcr in there and be done with this problem.
But I guess that didn't really solve the problem. I'm now guessing that I'm not allowing enough time for the device to receive the entire text from the paste before moving on to the next command. So maybe the device is still processing the long url text being pasted and ignores the later key commands. And maybe it also needs a little more time to switch from the text input screen back to opera mini.
I've added more delay after the paste and after leaving the text input window. See version 0.06b for this tweak and see if it helps. I've also taken out the second sendcr. If it works reliably, then the delays fixed it.
Code:
SendCtrlKey("V")
[b]Sleep(500)[/B]
SendLeftSoft
if ((opera_version_ini eq "4.1" AND direct_address_input eq True) OR (tried_again = True))
[b]Sleep(500)[/b]
sendcr
endif

[GUIDE] How To Make An Android App

Introduction
Hello and Welcome to android app development guide. In this [guide] i will teachyou how to develop applications for the android platform using java and some simple tools. I will also teach you to add audio/video to your apps and also teach how to make them location aware by adding gps function to it
Click to expand...
Click to collapse
What You Should Know
Here I am just letting you all Know the pre-requisites of making an app. But then if you dont match the pre-requisites..... its OKAY !! I started it without this xD
Some Experience Of Object Oriented Programming
Some Experience of JAVA
Experience of Using ECLIPSE
Have An ANDROID phone so that you know the capabilities of Android
Click to expand...
Click to collapse
Preface:Guide to make an android app
Click to expand...
Click to collapse
Setting Up the System
Setting Up the System
Downloading The Basic Equipment For Android App Development
Click to expand...
Click to collapse
Overview
Android Architecture
Runs on Linux 2.6
Dalvik Virtual Machine, Which Is optimised for mobiles
Integrated Browser, based On Webkit Engine
Optimized Graphics with Open GL ES
SQLite Database for Data storage
Click to expand...
Click to collapse
Android Application Fundamentals
Applications are written in JAVA programming Language
Compiled Into Android Package file (.apk)
Each Application runs in its own sandbox and linux processes
Applications consists of Components, Resources and a Manifest file
Click to expand...
Click to collapse
Components:
Activities
Single Screen with a UI [a screen seen by a user, it is an activity. basically a single screen, seen by the user IS an ACTIVITY ]
Multiple Activities are required to make a user friendly application
When a new activity starts, old activity is pushed on to the Back Stack [ it becomes handy and fast if you press the back button on the phone. the activity on the back stack is not needed to be loaded again ! ]
UI can be built with either by XML ( recommended) or in Java ( I hate doing that )
You can manipulate the lifetime of the activities by certain call back methods. such as onStart[], onPause[], etc.
Click to expand...
Click to collapse
Services
They perform long-running operations in the background.
Doesn't contain ANY user interface
Useful for network operations, playing music, etc.
Runs independently of the component that created it ! --> [ say a service that launches a Service is closed. the service is still running ]
They can be bound to other application components. [ IF allowed ]
Click to expand...
Click to collapse
Content Providers
Used to store and retrieve data and make it accessible to any application.
Since, there is no way to share data across the applications, it is the only way !
Exposes a public URI that identifies the data set with some unique method or codes.
The data is exposed by a simple table on a database model concept.
Android contains many providers for things like contacts, media, etc.
Click to expand...
Click to collapse
Broadcast Recievers
A component that responds to system-wide broadcast announcement.
For Example, if the battery is low, Android Sends a system-wide broadcast, and the application that is listening to it, is responded by a Broadcast Reciever.
Applications can also initiate a broadcast that different applications can respond to ! example --> if an application, app1, is dependent on another application, app2, it can start a broadcast for app2. if the app2 exists, it can proceed else it will pop up a message like --- "app2 doesn't exist. plz download it from the market"
They, like services, contain no UI
Can be used to create Status Bar Notifications
Click to expand...
Click to collapse
Android Manifest File
All applications MUST have an AndroidManifest.xml in its root directory.
Presents the information about the application to the Android System.
Declares the Components used in the application
Also Declares the permissions required from the user to run the application.
Declares the Minimum Android API level to run that application. [ eg: GingerBread, HoneyComb, IceCreamSandwich, etc. ]
Click to expand...
Click to collapse
Click to expand...
Click to collapse
Details About Some Folders
Have You ever Decompiled any apk file ?? If not, do it, cuz it is really important part of app making. since there are many relative things to this.
In here I will Explain about some folders you get to see in a folder named "res" when you decompile.
layout
In This Folder, You will find some xmls, which looks more like a web page source
And Gibberish until you take a CLOSE LOOK !
It actually stores in the Layout of your activity. You will get to be familiar with this as we are going to use this
Click to expand...
Click to collapse
drawable
In this folder, You will get the things that makes the app look beautiful !
Ha! This contains "pngs" that are used in themes. We Will come to this as time passes
Click to expand...
Click to collapse
xml
In here, Again, XMLs with someting Gibberish till you get a closer Look ! These xmls store your preference activities.
Click to expand...
Click to collapse
anim
This folder, again xmls, which seem more unreadable. This folder, as the name says, it stores the anim files that has instructions for your animations that you (will) use in the app.
Click to expand...
Click to collapse
values
This folder, again xmls, which seem even more unreadable. This folder, stores the values for different stuff, like ids, integers color hex's, etc (we will get to this later) .
Click to expand...
Click to collapse
colors
This folder, again xmls, as the name says, stores the colors that you (will be) using in the app (we will get to this later) .
Click to expand...
Click to collapse
Click to expand...
Click to collapse
Activities And Explicit Intents
Activities & Explicit Intents
As I've already told you that Activities are one of the primary building blocks of your app. here, we will learn how to create actiities, declare them in AndroidManifest.xml and We will also learn How to go to another activity from one activity. Okay. So now open up Eclipse. and sart a new Android Project.
Click on File >> New >> Android Project
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Fill in the details as you wish.... and click finish.
After you make a Project. You will get A full working Hello world Application. now, modify the MainActivity.xml in the graphical part like this
make a new xml file by clicking
. Give a file name like... SecondActivity.xml or something you like Note: This Will be your Second Activity. and now click Finish
Now drag the " TextView " from the " form widgets" tab from the left side panel to the graphical editor of your second activity.
Now, Basically what i want to teach is Explicit Intents. Now what we want our app to do is the text written in the MainActivity should be shown to the user when he clicks the "go to second activity" button. So to do this, we need to declare and do something with JAVA !
navigate to the .java files -->
Double click the java file and you will et something like this ( gibberish... if you dont like java like me )
since we need to define the "EditText" field and the "Button" from the first activity !
Now, find this
Code:
setContentView(R.layout.main);
after that start typing
final EditText et = findView
now press ctrl+space (windows)
it will show you a list of commands. choose findViewById(id)
now it will automatically place you along the (id). now start typing ---> R.id.
and press ctrl+space (windows).
chose the EditText Value..... Now as you see, it will show an error there. press ctrl+1 to show quick fixes. Add a cast to EditText. Final text will be Like this
Code:
final EditText et = (EditText) findViewById(R.id.editText1);
Now do the same with the "Button"
Code:
Button b = (Button) findViewById(R.id.button1);
Now that you have defined the button. Now you will have to set an OnClickListener for that button. so the it allows User to go to the second activity.
now start typing
b.setOnclick... press ctrl+space and choose onClickListener. It will automatically place you in the "()" type there --> new OnClickListener press ctrl+space. you will get something like this
you will get an error. so go to the place ( marked red in the pic and put a semi-colon )
now, in the following method,
Code:
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
start typing the following
Code:
Intent intent = newInt
press ctrl+space and choose this
It will automatically place you in packageContext.
NOTE:
packageContext == "The java file that is creating the Intent";
cls == " The java file to whom the Intent Should be passed";
so, edit it this way
Code:
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
NOTE:
MainActivity == "The java file that you are editing";
SecondActivity == " The java file That WILL represent the the SecondActivity.xml";
It will give you an error. press ctrl+1 and select--> create class "SecondActivity"
Fill in the details of the new java file and click finish. Now go back to previous java file.
Now, you have created an intent. But its not defined that what will that intent do !
So, now, Lets define that
start typing--> intent.putExtra and press ctrl+space. choose this.
now, you will be automatically placed in the "key". now for the key, you will have to type a string. i would like to call it "thetext". Now, Make sure you type the string WITHIN THE DOUBLE QUOTES..
For the value, you will have to give the reference of the "EditText" Field. here, i have given it as "et", i will type it this way.
intent.putExtra("thetext", et.getText().toString());
Click to expand...
Click to collapse
Now, you have successfully DEFINED what the intent does. but if you check the coding..... you will notice that the intent is never initialised ! now, to initialise it, type in this -->
startActivity(intent);
Click to expand...
Click to collapse
the final MainActivity.java should look like this.
Click to expand...
Click to collapse
Now, its almost done..... BUT.... ! what the hell is the use of the secondActivity.java ! ?
It is to be edited. only then the text written in the first activity by the user will be shown in the second activity. to do that, go to second activity. Now,
EASY PART
Find this in the first java file:
Copy all that stuff to the SecondActivity.java
Change the blue highlited text ( in eclipse ) to the name of the second xml file. (just dont add the extension)
Hard PART
Now, you gotta define the "TextView" on the SecondActivity.xml Since you have given the reference to the SecondActivity.xml by copying all that stuff.
so, start typing,
Code:
TextView tv = findView
NOTE: Here "tv" is the name you have assigned to the "TextView". You can change it if you want. BUT makesure you do the cahnges accordingly in the next steps.
hit ctrl + space. choose >> findViewById(id);
now again, as we already did that before, in the place of "id" just type in "R.id." hit ctrl+space and chose the "TextView"
Now, that You have defined it here, dosent mean that It will give you desired output....
You just have created an intent and have defined it and initialised it in the last java file.
But there is no-one to recieve that intent ! so, start typing the following:
And, in place of text, start typing "getI" and press ctrl+space. put a fullstop, type "getE" hit ctrl+space, put a fullstop again, start typing "getS", ctrl+space again now in the "()" put the string that you have defined in the last java file. since I have defined it as "thetext" i will type that in the "()" like this:
Code:
tv.setText(getIntent().getExtras().getString("thetext"));
Click to expand...
Click to collapse
Now, its done..... BUT.... ! .... AndroidManifest.xml
you didnt touch it till now. we have to register every activity there. or else, the app will cause a FC error. (Force Closes)
Now, open up the Androidmanifest.xml
go to the text editor :
and in the end before--> "</application>" add this
Code:
<activity
android:name="com.blksyn.explicitintents.SecondActivity">
</activity>
Click to expand...
Click to collapse
Now, its done. Lets start the emulator and Check this if it works !
Go to AVD Manager like this:
Start the AVD emulator.
click on run: and click on run again xD. Click on okay.
Bingo ! you have created an app which declares Explicit Intents and added a function to activities to catch that intent !
How to Make Android Apps: Explicit Intents
Click to expand...
Click to collapse
Implicit Intents
Implicit Intents
Now, you must have seen some applications with a "share" button. By clicking on this button, you can share a particular image/video/audio/etc....
What does that application actually do is send a message to other applications to search for the applications capable of handling such type of job. Then it pops up the list of such apps to the user. Now we can also have that list contain our app too !
Here is how.
Create a blank project. I gave it the name as "Implicit_intents". But you can choose whatever you want
Open up the "AndroidManifest.xml" file. (plz dont expect me to show how, cuz i have already shown that earlier and you should know that by now)
You will see something like this
Copy this from the main activity
Code:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
paste it again after the </intent-filter>
and change it to this
Code:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
NOTE:
Code:
<action android:name="android.intent.action.SEND" />
(self explainatory)
Click to expand...
Click to collapse
Code:
<category android:name="android.intent.category.DEFAULT" />
This tells the android system waht the category of the intent is. If you dont know what the category really is, you should keep it DEAFAULT.
Click to expand...
Click to collapse
Code:
<data android:mimeType="image/*" />
This tells the Android system, What type of data can the application "SEND" (* reference to the first one). and "data/*" means that the application can handle any type of imge. Jpeg, png, bmp, etc....
Click to expand...
Click to collapse
Click to expand...
Click to collapse
Click to expand...
Click to collapse
So, this is how your AndroidManifest.xml should look like.
Now, go to the xml of your main activity and get rid of that text view. and add an "ImageView" from "Images and media" tab on the left
Now, go to your main java file and give a refernece to that ImageView
NOTE: "iv" is just a name given to the ImageView. so, you can change it if you want. But you will have to adapt to it and make changes in the steps accordingly.
Import the image view thing and add a cast by hitting ctrl+space
Now that you have specified the ImageView, you now have to set the ImageView to show the image the user wanna send. so, start typing in "iv.setImage" and press ctrl+space.
Now, since the image is IN the intent sent by the gallery after the user clicks the share button, we have to "get" the "EXTRAS" from the intent. So, start typing in in the "()". "getInt" press ctrl+space put a "." again type "getExt" choose the only option available, put a "." again and type "get" choose the first option. now, for the key, we are gonna use a constant from the INTENT class, that is called "EXTRA_STREAM". So ,just start typing in "Intent", put a ".", type "extra_" and choose "EXTRA_STREAM".
This "EXTRA_STREAM" is nothing but the "URI" to the image the user wants to send. You will have an error now in the line even after putting a ";" in the end. so press the quick fix combo "ctrl+1" and add a cast to (URI).
Click to expand...
Click to collapse
Now, you have successfully built an application that can handle the "share" kind of intent. now if you run this app in the emulator, you will probably have an FC. Since the app does not have any intent to process during the launch, it will FC. but if you go to gallery and click on share, you will get this app in the list. And also, if you click on this app, you will see the image you wanted to share.
So, this ends our chapter of Implicit Intents. You can now use your imaginations and use the combos of the previous and this chapter to build a pretty good basic app ! and the credit will be yours ! But dont forget to thank me for my efforts. haha... and also if i help you in some place.
And last but not the least in this chapter, If you have any questions, post a reply in this thread you will surely be answered :good:
How to Make Android Apps: Implicit Intents​
Click to expand...
Click to collapse
Widgets
I am going to teach you how to make a widget.
This widget will go to a specified site !
So , make a new android application in eclipse
name it whatever you like !
Click on File >> New >> Android Project
Fill in the details as you wish.... and click finish.
After you make a Project. You will get A full working Hello world Application. Now, modify the activity_main.xml in the graphical part like this
You will get something like this:
Now Open Up the AndroidManifest.xml. and remove this part:
And add this part:
make a new xml file by clicking
. and change Resource type from Layout to "AppWidget Provider" and now click Finish
Note: This Will be your android:resource file. highlighted in the previous image.
Now Open up that xml. You will find it in the /res/xml directory. you will get something like this:
Now click on the "red" underlined part. you will get something like this:
Now, Basically we are making a 2x2 widget. You need to specify that somewhere right ? That is the place. but how do you specify ?? It can be calculated using this formula:
Code:
the min width =
[(number_of_cells) * 74] - 2
2x2
min widht = [2*74]-2 = 144
min height = 144 ! :)
so, fill in the details like this:
Now, the layout part of the widget is complete. What we want to do is the JAVA thing now. So, open up the MainActivity.java
Double click the java file and you will et something like this
since we Are making a widget, We cannot have Much functions in here. Unlike activities(which have loads of functions in it) widget restricts us to very few. So, we are not going to need all the stuff You are seeing in java file. so do one thing. delete all the things. Here is how it shoud look like:
Now, Since We are not making a regular activity, We are not going to extend activity. Now we are going to extend the "AppWidgetProvider"
Code:
public class MainActivity extends AppWidgetProvider {
Now "AppWidgetProvider" Does not allow "OnCreate" Methods. what we are allowed is onUpdate Method, Since this is going to be called every single time our widget updates (N/A in this widget, but still you have to write it)
In that method, start typing
Code:
onUpdate
now press ctrl+space (windows only)
You will have something like this:
Code:
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
In this class you have to define everything. Now what we are going to do is we will have to define a for loop:
Code:
for(int i = 0; i<appWidgetIds.length; i++){
}
Now first thing in this for loop, we are gonna have to refer to our current appWidgetID. so,
Code:
int ID = appWidgetIds[i];
Done! now wahat we are goingg to do with this widget ??
ANS: We are going to launch a web site b opening our browser.
Okay, so how are we going to do it ??
Yes, exactly. like we did it before, we are going define an intent, like this:
Code:
Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse("URL_OF_YOUR_WEBSITE"));
Now, It still isnt going to launch anything. What we have to do, is, set a "PendingIntent".
A pending intent is actually an intent which gives access to, um, ur app (widget, in this case,). so, start typing in
Code:
Pending
press ctrl+space. name it what you want. then put " = " . again type "PendingIntent." and press ctrl+space and select this:
Code:
getActivity(context, requestCode, intent, flags)
Now, for context, it has olready defined in your context (onUpdate method).
requestCode = flags 0 (we aren't using them here)
and for intent, put your intents name like I've put in "in". it will look something like this:
Code:
PendingIntent pen = PendingIntent.getActivity(context, 0, in, 0);
NOW, SINCE THIS IS A WIDGET AND NOT A SIMPLE, REGULAR ACTIVITY, WE CAN'T USE THE "findViewById(id)" THING HERE, WE HAVE TO USE "RemoteViews" since these views are
in the widget and not public.
So, we are going to create new instance of this
type in,
Code:
RemoteViews view = new Re
and press ctrl+space an choose this:
Code:
RemoteViews(packageName, layoutId)
for package name:
for layoutId:
Code:
R.layout.activity_main
now, after this, like we set onClickListener, We have to set onClickPendingIntent
like this:
Now, give respective arguments in the brackets. The final thing should look like this:
Code:
view.setOnClickPendingIntent(R.id.imageButton1, pen);
NOW, Last thing. it is to set up an "appWidgetManager"
so, Start typing:
and give the respective arguments.
final MainActivity.java should look like this
It wil Never launch a browser yet,, think why ???
We havent yet given up the permissions yet !!!
So, open up the AndroidManifest.xml
Go to permissions tab, youll see something like this:
click on Add.
edit like this.
Click to expand...
Click to collapse
Now, its done. Lets start the emulator and Check this if it works !
Go to AVD Manager like this:
Start the AVD emulator.
click on run: and click on run again xD. Click on okay.
Bingo ! you have created aWidget !!
Audio/Video and multimedia
Audio
In this one, i will tell you how to use the "raw" folder to play audio(s) from the folder using MediaPlayer thingy. Okay. So now open up Eclipse. and start a new Android Project.
Click on File >> New >> Android Project
Fill in the details as you wish.... and click finish.
After you make a Project. You will get A full working Hello world Application. now, modify the MainActivity.xml in the graphical part by adding a button to it and save it.
Now, in the project, right click on res folder, new>>folder. name the folder as "raw". THEY ALL SHOULD BE IN SMALLS. NONE OF THE LETTER SHOULD BE IN CAPS
Now, have a short mp3 file like the one in attachments, and drag it to the newly created folder.
Now, its all set, what our app will do is it will play that short mp3 file i the "raw" folder as soon as we press that button. Now, for that sake we are going to use MediaPlayer class. Open up the MainActivity.java fir this.
navigate to the .java files -->
Double click the java file and you will et something like this ( gibberish... if you dont like java like me )
we need to define the field and the "Button" from the first activity !
NOTE: as we advance in the tutorial, i will assume that you have done it from the start, hence i will not show such small things everytime, to make the tut short, sweet and simple. refer the first tutorial for this step.
It should look like this:
Code:
Button b = (Button) findViewById(R.id.button1);
Now that you have defined the button. Now you will have to set an OnClickListener for that button. so the it allows User to go to the second activity.
now start typing
b.setOnclick... press ctrl+space and choose onClickListener. It will automatically place you in the "()" type there --> new OnClickListener press ctrl+space. you will get something like this
you will get an error. so go to the place ( marked red in the pic and put a semi-colon )
now, in the following method,
Code:
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
start typing the following
Code:
MediaPlayer mp = MediaPlayer.
press ctrl+space and choose this
It will automatically place you in "context".
NOTE:
context == "The java file that is creating the Intent";
resid == " The id of the resource (here, id of the mp3 file in the folder"raw")";
so, edit it this way
Code:
MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.beep);
NOTE:
MainActivity == "The java file that you are editing";
R.raw.beep == "Here , the name of the mp3 file in my "raw" folder is beep, it can be according to you";
So, we have just defined the mp class.
BUT, who is invoking it ?
Nobody, we need to invoke it ourselves. here, there is no relation or job to be done by "intent" like we did in earlier tutorials MediaPlayer class is totally different....
We need to do this in order to invoke.
Code:
mp.start();
NOTE:
mp == "the name that i gave to MediaPlayer object";
Code:
MediaPlayer [COLOR="SeaGreen"]mp[/COLOR] = MediaPlayer.create(MainActivity.this, R.raw.beep);
.
Click to expand...
Click to collapse
Save it and run it on your AVD
Now, its done. Lets start the emulator and Check this if it works !
Go to AVD Manager like this:
Start the AVD emulator.
click on run: and click on run again xD. Click on okay.
YAY ! it works !! click on that button
Click to expand...
Click to collapse
Video
In this one, I will tell you how to play video(s) which are already in your sdcard. Okay. So now open up Eclipse. and start a new Android Project.
Click on File >> New >> Android Project
Fill in the details as you wish.... and click finish.
After you make a Project. You will get A full working Hello world Application. now, modify the MainActivity.xml in the graphical part by adding a button to it and save it.
Now, place a video in ur sdcard (wherever you want, will explain later).
NOTE:
Video should be in mp4 format, as android has built-in encoders for that.
Now, its all set, what our app will do is it will play that short mp4 video file in the sdcard as soon as activity is invoked. Now, for that sake we are going to use VideoView class.
Go to res/layout/activity_main.xml
Delete the text view and add a VideoView:
Save it
Open up the MainActivity.java like this.
navigate to the .java files -->
Double click the java file and you will see something like this ( gibberish... if you dont like java like me )
we need to define the VideoView class.
NOTE: as we advance in the tutorial, i will assume that you have done it from the start, hence i will not show such small things everytime, to make the tut short, sweet and simple. refer the first tutorial for this step.Its just like defining a button
It should look like this:
Code:
VideoView vv = (VideoView) findViewById(R.id.videoView1);
Now that you have defined the VV. Now you will have to set properties of the VV so that we can play the video and offer controls(rewind, play/pause, fast fwd) and etc.
now start typing
vv.setV... press ctrl+space and you will get something like this
choose that, and enter string path:
Code:
vv.setVideoPath("/sdcard/path/to/video.mp4");
note that the /sdcard is a must. it can also be written as /mnt/sdcard/ however. not all phones have this functionability.
so, its better to write /sdcard.
Since we need to have controls while playing the video, we need to instantiate that first, so,
Code:
vv.setMediaController(new MediaController(this));
Disstection:: MediaCOntroller, Name explains itself. since we didnt create the MediaController anywhere, we made a new controller
and passed in the context as "this"
-_- "java". lol
Now that we want to start it as soon as the activity is started.
we add this:
Code:
vv.start();
we also do not want the backlights to be down while playing the video so,
Code:
vv.requestFocus();
Save it and run it on your ACTUAL ANDROID DEVICE.
NOTE: Please do not test this on emulator.[/size]
Click to expand...
Click to collapse
Images and Camera
In this one, i will tell you how to use the Mediastore and device's camera to get the picture/photo from the camera. Okay. So now open up Eclipse. and start a new Android Project.
Click on File >> New >> Android Project
Fill in the details as you wish.... and click finish.
After you make a Project. You will get A full working Hello world Application. now, modify the MainActivity.xml in the graphical part by adding a button to it and save it.
Now, its all set, what our app will do is it will click a picture using device's camera, and give you the picture. so, open up your main_activity.xml and delete the TextView. Add a button (which will initiate device's camera) and an ImageView (which will show you the pic that the user will click).
Then open up your MainActivity.java
navigate to the .java files -->
Double click the java file and you will et something like this ( gibberish... if you dont like java like me )
we need to define the field and the "Button" from the first activity !
NOTE: as we advance in the tutorial, i will assume that you have done it from the start, hence i will not show such small things everytime, to make the tut short, sweet and simple. refer the first tutorial for this step.
It should look like this:
Code:
Button b = (Button) findViewById(R.id.button1);
Now that you have defined the button. Now you will have to set an OnClickListener for that button. so the it allows User to go to the second activity.
now start typing
b.setOnclick... press ctrl+space and choose onClickListener. It will automatically place you in the "()" type there --> new OnClickListener press ctrl+space. you will get something like this
you will get an error. so go to the place ( marked red in the pic and put a semi-colon )
now, in the following method,
Code:
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
Make an instance on Intent
Code:
Intent intent = new Intent();
now in the arguments, pass in "android.provider.MediaStore.ACTION_IMAGE_CAPTURE"
this allows us to actually launch the camera app(s) installed on the device. so as to
get a captured image.
Till now, we started intents just like starting any activity.
but in this particular case, we are starting another activity,
with an expectation of recieving some data back.
that is, result.
so, next, start typing "startAct...."
and choose this
Code:
startActivityForResult(intent, requestCode)
NOTE:
intent = "The Intent that we already created"; (since I've named it as "intent" , ill pass in
"intent")
requstCode == "we will not be using this, so, skip it, pass in a zero";
Code:
startActivityForResult(intent, 0);
now then, we are expecting a result.
so, we must set a reciever for it, right ?
lets do that first and then play with the ImageView
so, after the method, make a new method, start typing
Now, we have set the reciever.
now, we need to give an instance of ImageView.
so, declaration has to be before the onCreate method.
and definition can be in both the methods.
so, declare an ImageView outside the onCreate method
Code:
ImageView iv;
and in the onCreate method,
Code:
iv = (ImageView) findViewById(R.id.imageView1);
and lastly, in the onActivityResult method,
declare and define a bitmap, which will save the clicked pic.
Code:
Bitmap bm = (Bitmap) data.getExtras().get("data");
now, bm will save the clicked pic in itself.
and to display it, we use iv. so type in this:
Code:
iv.setImageBitmap(bm);
At The End, this is how the MainActivity.java should look like:
Code:
package com.example.camtut;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends Activity {
ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iv = (ImageView) findViewById(R.id.imageView1);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Bitmap bm = (Bitmap) data.getExtras().get("data");
iv.setImageBitmap(bm);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
[/hide]
Click to expand...
Click to collapse
Now, its done, Check this if it works !
P.S. do not use emulator for this, test it on actual device
Click to expand...
Click to collapse
https://www.youtube.com/watch?v=HpmjwddBdxY
Click to expand...
Click to collapse
Apology for the delay (over one year )
but I will start writing this off afresh will include something more too
stay tuned
Regards,
Nachiket.Namjoshi
Thank you all of you for your support...
Since there are MANY time issues right now,
I will be updating this guide whenever I get time...
I hope you all understand.​
Reserved for GPS and stuff
Sent from my GT-S5360 using xda app-developers app
5 more to be reserved for the sake of finding them on one place
Sent from my GT-S5360 using xda app-developers app
4 more
Sent from my GT-S5360 using xda app-developers app
3 more
Sent from my GT-S5360 using xda app-developers app
2 more for really important stuff
Sent from my GT-S5360 using xda app-developers app
Done.... it's the last one
Sent from my GT-S5360 using xda app-developers app
great bro. You reserved a lot
thanks
The JRE and JDK link is not working. Also downloading the JDK alone contains the JRE package, and downloading JRE separately is not needed.
Link: http://www.oracle.com/technetwork/java/javase/downloads/jdk6u38-downloads-1877406.html (JDK6 is recommended to use with Android development, as JDK7 has compatibility issues)
coolsandie said:
The JRE and JDK link is not working. Also downloading the JDK alone contains the JRE package, and downloading JRE separately is not needed.
Link: http://www.oracle.com/technetwork/java/javase/downloads/jdk6u38-downloads-1877406.html (JDK6 is recommended to use with Android development, as JDK7 has compatibility issues)
Click to expand...
Click to collapse
Thanks bro... I did it from the xda app. So plz forgive...
Sent from my GT-S5360 using xda app-developers app
nice work on it....cool bro but update links

[Q] My chinese tablet got into DEMO mode.

Hi, i bough a chinese tablet a few weeks ago.
I didnt intalled anything bad or risky in it.
And this night i got unexplicable popups, adds and applications that i didnt installed.
The source of this activity was a app called com.android.server and com.android.popupreciver
I unistalled them and then i rebooted my tablet, then i got a message saying DEMO.
I heard that the only way to solve this is a hard reset, but i would like to know if there is something else i can do.
=====
Else, i would like to know if there is any ROM compatible for a 7" chinese tablet.
Removing Demo mode from Chinese tablets
I have one of these and have not been using it for a long time due to all the unwanted ads and being unable to figure it out. The other day I decided to give it another try and this is what I found:
A lot of these cheap tablets comes with a trojan and on my A23 Q8H 7" tablet it was in CloudsService.apk. If you remove it the tablet will show big red "Demo" letters across the screen. This comes from the SystemUI.apk and when I decompiled it I saw the following:
Code:
private void showDemoOverlay() {
TextView textview = new TextView(this);
textview.setText("Demo");
textview.setTextSize(180F);
textview.setGravity(17);
textview.setBackgroundColor(0);
textview.setTextColor(0xffff0000);
android.view.WindowManager.LayoutParams layoutparams = new android.view.WindowManager.LayoutParams();
layoutparams.type = 2006;
layoutparams.width = -1;
layoutparams.height = -2;
layoutparams.gravity = 17;
layoutparams.format = textview.getBackground().getOpacity();
layoutparams.flags = 24;
((WindowManager)getSystemService("window")).addView(textview, layoutparams);
}
The above function in SystemUIService.java is indirectly called by this one
Code:
private boolean hasOTAServer() {
android.content.pm.PackageInfo packageinfo;
try {
packageinfo = getPackageManager().getPackageInfo("com.clouds.server", 0);
}
catch (android.content.pm.PackageManager.NameNotFoundException namenotfoundexception) {
packageinfo = null;
namenotfoundexception.printStackTrace();
}
return packageinfo != null;
}
So in short all it does is look for is a package called com.clouds.server and if it doesn't find it the Demo is displayed.
The solution is to create a blank app in Android studio, make sure the package name is com.clouds.server and then install it on the device.
Now this I call informed investigation! I was trying to get rid of the trojan on a chinese tab and after removing at least 5 apps and rebooting i got the DEMO overlay.
I found a blog post dealing with the same problem and this person provided an APK to install (I checked it via virustotal and it came back clean): cmcm.com/article/share/2015-11-09/840.html
How did you find out it was the SystemUI.apk showing the overlay? Or was it just an educated guess? I tried finding the app via dumpsys but couldn't see anything...
P.S.: THANKS!!
Surrogard said:
Now this I call informed investigation! I was trying to get rid of the trojan on a chinese tab and after removing at least 5 apps and rebooting i got the DEMO overlay.
I found a blog post dealing with the same problem and this person provided an APK to install (I checked it via virustotal and it came back clean): cmcm.com/article/share/2015-11-09/840.html
How did you find out it was the SystemUI.apk showing the overlay? Or was it just an educated guess? I tried finding the app via dumpsys but couldn't see anything...
P.S.: THANKS!!
Click to expand...
Click to collapse
It has been a while but if you extract all the APK files and run grep on them you should be able to find the one you are looking for. You can then decompile the APK to have a look at the source code. Another way would be to remove the apps one by one and reboot each time. When you find the APK which causes the Demo mode to be activated just replace it with a blank APK file with the same package name and it should be good. If that does not work then it could be that the tablet checks for more things which means you'll have to go with option 1. I would also not trust virustotal with this as there are many reasons why it could return a false result and it does not take too much skills to bypass virustotal checks.
The solution!
Just install a clean CloudsService.
Normal_CloudsService.apk
Mirror1: https ://drive .google .com/file/d/0B1CH2n58TrbiSFl4Y0twRk5LX3M/view?usp=sharing
Mirror2: https ://drive .google .com/file/d/0B65Tvd8zpsRPOFNLY2NTRVMxckU/view?usp=sharing
VirusTotal: https ://www .virustotal .com/en/file/a014b81ce3cbee336a705eb54a0d6081038d67cc34b65688304a3ee41861903a/analysis/1455333414/
cheers
ofernandofilo said:
Just install a clean CloudsService.
Normal_CloudsService.apk
Mirror1: https ://drive .google .com/file/d/0B1CH2n58TrbiSFl4Y0twRk5LX3M/view?usp=sharing
Mirror2: https ://drive .google .com/file/d/0B65Tvd8zpsRPOFNLY2NTRVMxckU/view?usp=sharing
VirusTotal: https ://www .virustotal .com/en/file/a014b81ce3cbee336a705eb54a0d6081038d67cc34b65688304a3ee41861903a/analysis/1455333414/
cheers
Click to expand...
Click to collapse
Thank you!
Note that you might need to do
adb uninstall com.clouds.server
before you will be able to install this one if you get "Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]"
it works
I JUST INSTALLED THE APK POSTED IN THE FIRS LINK ... AND IT WAS MY SOLUTION..... I DO IT TO ZEEPAD 7DRK
---- drive.google.com/file/d/0B1CH2n58TrbiSFl4Y0twRk5LX3M/view#! -------
GREETENGS FROM MEXICO LEON GTO
....my english is bad .. i know i know.... jajajaj lool

Notification Limit per app - Android Q

Using a Q rom on my Sammy note 9 (exynos; with august security update).
On Q, android system notification is limited to 24 per app (on P it was 49).
Notifications beyond 24 are not showing in notification panel.
Anyone knows how to change it to 49 or even higher? What files / code should be modified and how? the 24 limit is unusable...
Thanks :fingers-crossed:

			
				
@BADtoBONE
The notification limit per app is hardcoded: MAX_PACKAGE_COUNT. You can observe this in the NotificationManagerService.java source code what is part of package com.android.server.notification.
Thanks!
I can't find the package. Can you verify the location?
Can I change it manually via root explorer to 75 for example? any effects of the phone or OS performance?
Anyone know a tutorial to allow more than 24 notifications?
Still stuck with this issue.
Saw this online -
If you run a custom rom/magisk you can patch services.jar to increase the MAX_PACKAGE_NOTIFICATIONS to 100. [/QUOTE said:
Anyone knows a Magisk module to fix that?
Currently running a custom rom but unable to locate and change the package settings.
Thanks!
Click to expand...
Click to collapse
BADtoBONE said:
Still stuck with this issue.
Saw this online -
Click to expand...
Click to collapse
Hah that was me.
I diddn't find a great way to do it in a way that works generally, but you can use - https://forum.xda-developers.com/t/module-smali-patcher-7-3.3680053/ to make it easier to patch the file yourself. You'd want to patch the enqueueToast function.
I'm having the same problem too, I migrated from iOS to Android in April, and it is incredibly frustrating that notifications from an app are dropped after they reach 50, in iOS there is no limit. I've tried extracting "services.jar" to locate "NotificationManagerService.java" to patch the "MAX_PACKAGE_NOTIFICATIONS" count to higher than 50, but it wouldn't work. I had great difficulty even extracting the .jar to begin with. I tried extracting it to .java, but it kept coming up with errors, so it wouldn't extract it fully. I had to resort to extracting it to the .smali format (using apktool, baksmali etc), which extracted it fully, at least to the best of my knowledge, but it is very hard to read. I was able to locate "MAX_PACKAGE_NOTIFICATIONS", which reported a count of "0x32" (50 in hexadecimal), so I changed it to "0x3e7" (999 in hexadecimal), but it didn't work, it still stopped at 50.
@ajolly
I noticed on Twitter that you seemed to be able to successfully remove the limit:
twitter.com/jolly/status/1201266208944705536
May I ask, how did you end up doing this? You mention using "smalipatcher", but when I run it, it doesn't mention "enqueueToast" anywhere, unless I'm missing a step. Forgive my naiveness, I am still rather new to the whole "Android tinkering" scene.
Any help would be greatly appreciated, as this is driving me up the wall.
Thanks
Following.
I run MIUI 12.6 and the limit is set to 9 or 10. I would love to find a way to change the limit as well.
Thanks!
_csd said:
I'm having the same problem too, I migrated from iOS to Android in April, and it is incredibly frustrating that notifications from an app are dropped after they reach 50, in iOS there is no limit. I've tried extracting "services.jar" to locate "NotificationManagerService.java" to patch the "MAX_PACKAGE_NOTIFICATIONS" count to higher than 50, but it wouldn't work. I had great difficulty even extracting the .jar to begin with. I tried extracting it to .java, but it kept coming up with errors, so it wouldn't extract it fully. I had to resort to extracting it to the .smali format (using apktool, baksmali etc), which extracted it fully, at least to the best of my knowledge, but it is very hard to read. I was able to locate "MAX_PACKAGE_NOTIFICATIONS", which reported a count of "0x32" (50 in hexadecimal), so I changed it to "0x3e7" (999 in hexadecimal), but it didn't work, it still stopped at 50.
@ajolly
I noticed on Twitter that you seemed to be able to successfully remove the limit:
twitter.com/jolly/status/1201266208944705536
May I ask, how did you end up doing this? You mention using "smalipatcher", but when I run it, it doesn't mention "enqueueToast" anywhere, unless I'm missing a step. Forgive my naiveness, I am still rather new to the whole "Android tinkering" scene.
Any help would be greatly appreciated, as this is driving me up the wall.
Thanks
Click to expand...
Click to collapse
Smalipatcher will pull the services.jar file for you, then you can decompile it.
The code is something like:
// Limit the number of toasts that any given package except the android
// package can enqueue. Prevents DOS attacks and deals with leaks.
if (!"android".equals(pkg)) {
int count = 0;
final int N = mToastQueue.size();
for (int i=0; i<N; i++) {
final ToastRecord r = mToastQueue.get(i);
if (r.pkg.equals(pkg)) {
count++;
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
Slog.e(TAG, "Package has already posted " + count
+ " toasts. Not showing more. Package=" + pkg);
return;
}
}
}
Warning, at least for me when I put it too high binder would start crashing, I set it to 99.

Noob question about apk

So this is my first time publishing an Android app. Now I successfully convert my aab into apks and then unzip it into many smaller apk. However, now I am confused about which one should I send to my beta tester? There is so many different apk like
standalone-arm64_v8a_hdpi.apk
standalone-arm64_v8a_mdpi.apk
standalone-arm64_v8a_xxxhdpi.apk
standalone-armeabi_v7a_mdpi.apk
and many more. I am guessing we need to match the apk for the specific device? However, if I want to upload my apk into a website and the user can download the apk directly from the website in the future. which apk should I upload then? Since it's impossible to determine the device info beforehand? Hope my question make sense. Thanks
Jimbotron126 said:
So this is my first time publishing an Android app. Now I successfully convert my aab into apks and then unzip it into many smaller apk. However, now I am confused about which one should I send to my beta tester? There is so many
...
upload then? Since it's impossible to determine the device info beforehand? Hope my question make sense. Thanks
Click to expand...
Click to collapse
Those version of your apk are for users running different chipset and different screen dpi. Those apks are uplaoded to google play, and when someone downloads the app, it's the right apk for them that gets installed right away (they don't have to choose).
From my experience, screen dpi isn't a problem when installing, the only problem you could face is when installing arm64_v8a on an armeabi_v7a device (installing 64bit app on a 32bit device). 32bit devices tend to be rarer and rarer so if you had to post your app for testing it would be any of the arm64 apk + any of the armeabi_v7a apk.
Because probably an Android user neither knows about the meaning of the DPI-bucket-shorthands ( MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI) or ABI-shorthands, IMO it's recommended to offer in your web-site to your users a Powershell script to download what either by means of ADB gets Android device's DPI-bucket-setting & ABIs supported and then automatically selects the proper APK to get downloaded or provides a simple menu where users can select the matching APK related to their phone's ABI and/or DPI to get downloaded.
Read more here:
Use PowerShell to download a file with HTTP, HTTPS, and FTP
In PowerShell, you can download a file via HTTP, HTTPS, and FTP with the Invoke-WebRequest cmdlet
4sysops.com
Example Powershell menu skeleton:
Code:
do
{
Show-Main-Menu
$selection = Read-Host "Please make a selection"
switch ($selection)
{
'1' {
Show-DPI-Menu
} '2' {
Show-ABI-Menu
}
}
pause
}
until ($selection -eq 'q')

Categories

Resources