Context:
Earlier this year Facebook updated their android app without using the google play services : http://liliputing.com/2013/03/facebook-pushes-android-update-to-enable-silent-updates-bypassing-the-play-store.html
I would like to try a similar thing with my android app.
(I'm aware of the implications so please don't post regarding the same.)
Description:
I have gone through the the related Android classes Package Manager - Androidxref and resources like: Install apps silently, with granted INSTALL_PACKAGES permission but could not find any non-rooted method.
Ways like:
public static int installAPP(String absolutePath){
int status = -1;
File file = new File(absolutePath);
if(file.exists()){
try {
String command = "adb install -r " + StringUtil.insertEscape(absolutePath);
Process install = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
status = install.waitFor();
} catch (Exception e) {
Log.e(TAG, "Not Installed!");
} finally { return status;}
}
}
works just fine, but then again it's for rooted devices.
Any information/hints for possible ways of doing and and any relevant information/hacks regarding the same is much appreciated.
Thank You.
PS. I am working on a ROM.
Related
I've recently tried to install the QDK via the VSCode extension in my Windows 10 Desktop and VSCode wasn't able to find the Microsoft libraries even after I was able to execute the code by the dotnet run command on the terminal. The code was the sample project code described in the create new project part of the tutorial. I also didn't have .NET SDK so I installed it but it seems to be working fine. In computers I got problems all the code, all related to not finding the namespaces.
namespace QuantumRNG {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Measurement;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
operation GenerateRandomBit() : Result {
using (q = Qubit()) {
H(q);
return MResetZ(q);
}
}
operation SampleRandomNumberInRange(max : Int) : Int {
mutable output = 0;
repeat {
mutable bits = new Result[0];
for (idxBit in 1..BitSizeI(max)) {
set bits += [GenerateRandomBit()];
}
set output = ResultArrayAsInt(bits);
} until (output <= max);
return output;
}
#EntryPoint()
operation SampleRandomNumber() : Int {
let max = 50;
Message($"Sampling a random number between 0 and {max}: ");
return SampleRandomNumberInRange(max);
}
}
Do you see any error messages in the output console?
To see the output console select "View: Toggle Output" (Ctrl + Shift + U) and select "Q# Language Extension" from the drop down list.
If the drop down list doesn't show "Q# Language Extension" then it probably means that the language-server that gets downloaded on first run is still downloading, so give it a minute or so (depending on your internet connection).
I think I also had the same problem. The .Net SDk which you have downloaded automatically creates a path in the environment variable by the name "%USERPROFILE%.dotnet\tools" so delete this and add "C:\Program Files\dotnet\sdk" or copy the path of dotnet SDK from the drive where you have installed dotnet and create a new environment variable under user variable. This might solve your namespace problem.
I load images from my local destination to unity the code is:
Texture2D imgTexture;
using (UnityWebRequest req = UnityWebRequestTexture.GetTexture(filePath))
{
yield return req.SendWebRequest();
if (req.isNetworkError)
{
Debug.Log(req.error);
}
else
{
imgTexture = DownloadHandlerTexture.GetContent(req);
}
}
it works on pc but when I run on android emulator I get an error
Cannot connect to destination host
the local file directory comes from simple file browsing plugin so I am thinking directory cannot be wrong.
is it a permission problem how can I fix this?
The keyword here is Web. I can get the build and version number of a Flutter app by using the package_info plugin, but if it is running on the web I can't. How do I get the package info for a Flutter Web app?
I'll include an answer below as a temporary fix, but I am looking a solution that gets the version info from pubspec.yaml.
As a temporary workaround you can create a separate file with the version info in it:
web_version_info.dart
class WebVersionInfo {
static const String name = '1.0.0';
static const int build = 1;
}
You can use that for all platforms or in your code you can use kIsWeb to just use it for the web:
Future<String> _getAppVersion() async {
if (kIsWeb) {
return WebVersionInfo.name;
} else {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
}
}
Of course, this is not a great solution because now you need to remember to update the version and build information in both pubspec.yaml and in WebVersionInfo every time you update the app.
If you use beta channel you can use package_info_plus plugin that appears to be a drop-in-replacement for package_info. So all you need to change is pubspec.yaml and your import. (I only use version so there could be differences that I haven't noticed)
Change pubspec and your import
pubspec.yaml: package_info_plus: '>=0.6.3 <2.0.0'
import: import 'package:package_info_plus/package_info_plus.dart'
Reference:
Github issue 46609
For those using Linux and in order to improve Suragch's answer, I suggest automating the build process using bash scripts. For that, we need two scripts: one to increase the version build number and another to call the flutter build command itself, forwarding the parameters. That way, if you prefer to just increment the version build number manually, you can just call the update script and then 'flutter build' later, but if you want to do everything in one step, you can call the builder script.
You will only need to edit the '.app_version' file as the version changes.
The '.build_seq', '.version_number' files are always rewritten, and the '.app_version' file is created only if it is not found.
The scripts:
updversion.sh:
#!/bin/bash
if [ -f ".app_version" ]; then
VER=`cat .app_version`
else
VER="1.0.0"
echo $VER > .app_version
fi
if [ -f ".build_seq" ]; then
BLD=`cat .build_seq`
else
BLD='0'
fi
((BLD++))
echo $BLD > .build_seq
echo "Ver: $VER ($BLD)" > .current_version
echo "
// Auto-generated by updversion.sh. Do not edit.
class WebVersionInfo {
static const String name = '$VER';
static const int build = $BLD;
}
" > lib/version_info.dart
exit 0
buildweb.sh:
#!/bin/bash
./updversion.sh
flutter build web $*
exit $?
I am trying to use wget with my Android app, which targets Android v 4.2.2. I granted the app Internet permission thru the AndroidManifest.xml file, but that did not solve the issue. I am still unable to download the file with wget command. I also tried to use a java socket to accomplish the connection to the server and download the file, however, that did not work. It seems that Android version 4.2.2 has restrictions on allowing network access thru Android apps. Could someone please help me identify a work around for getting network access so wget command can work from the Android app? Below is the code I am using to test the command.
private String runShellCommand() {
try {
Process process = Runtime.getRuntime().exec("system/bin/wget -O /data/data/com.shell/filename http://url to the file");
InputStreamReader reader = new InputStreamReader(process.getInputStream());
BufferedReader bufferedReader = new BufferedReader(reader);
int numRead;
char[] buffer = new char[5000];
StringBuffer commandOutput = new StringBuffer();
while ((numRead = bufferedReader.read(buffer)) > 0) {
commandOutput.append(buffer, 0, numRead);
}
bufferedReader.close();
process.waitFor();
return commandOutput.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
Your goal seems to be to download a file rather than using wget correctly. To download the file within your app, which is the conservative and portable solution, try using the URL class and the HttpURLConnection class, or other classes available on android and suitable for downloading based on URLs.
How to see console.log messages of a website using android emulator?
From Rich Chetwynd's short article "Javascript debugging on Android browser".
You can log javascript errors and console messages from your Android device or emulator. To do this you first need to install the Android SDK and USB drivers and enable USB debugging on the actual device.
To check if the device is connected correctly you can run the following cmd from your Android SDK tools directory and you should see a device in the list
c:\android sdk..\platform-tools\adb devices
You can then use the Android Debug Bridge to filter debug messages so that you only see browser related messages by running the following cmd.
c:\android sdk..\platform-tools\adb logcat browser:V *:S
By default the log is written to stdout so you will see any Javascript errors or console.log messages etc written to the cmd window.
Further details: Logcat CLI tool docs.
If you have started the emulator from Eclipse with the ADT plugin, you will see all JavaScript console logs directly under the LogCat view :
Window -> Show View -> Android -> LogCat
If you are using Android Studio; you can open your Logcat (Alt+6) and filter for: :CONSOLE
Filtering for only :CONSOLE (rather than INFO:CONSOLE) will display all types of console messages (including ERROR, WARN, etc).
You could add some JavaScript temporarily like...
var console = {
log: function(msg) { alert(msg); }
};
Ugly as hell, but it works.
I hijacked the console.log using this code:
function logManager() {
var self = this;
self.init = function () {
console.log('logmanager initialized');
var old = console.log;
self.logger = document.getElementById('log');
console.log = function (message, options) {
if (typeof message == 'object') {
self.logger.innerHTML = (JSON && JSON.stringify ? JSON.stringify(message) : message) + '<br />' + self.logger.innerHTML;
} else {
self.logger.innerHTML = message + '<br />' + self.logger.innerHTML;
}
}
}
self.toggleLogVisibility = function () {
return $(self.logger).toggle();
};
}
And consume it like so in your html with your own styling (absolute top right is what I used)
<div id="log" class="log">
Application loaded...
</div>
And in your jscript (run this on page loaded as the log element has to exist)
document.lmgr = new logManager();
document.lmgr.init();
Open this url on your chrome
chrome://inspect
Command - get log from the emulator
adb -e logcat
adb.exe can be found at $your_installation_path$\android sdk\platform-tools
more detailed
https://learn.microsoft.com/ru-ru/xamarin/android/deploy-test/debugging/android-debug-log?tabs=windows
If you cannot run adb logcat browser:V *:S because of zsh, you need to run noglob adb logcat browser:V *:S. Rationale: https://github.com/ohmyzsh/ohmyzsh/issues/2901