Dokan (DokanNet.dll) on Android/Monodroid - Code Migration Issue - android

Context:
I have an windows desktop app(c#) which loads the dokan libraries , creates a new file system/drive each time it runs, and then deploys financial data files & copywrite protected files in the newly created drive - Allowing only limited process (declared by me) to have access to these files in newly created file system(using dokan).
Now we are migrating the same C# code to android. Though the code doesn’t give Errors, (while running apk)the new drive is not created. While i could debug only to an extent (suddenly get out of debugging mode)
Assumptions for the issue:
Permission issues:
Question:
Does Dokan work with Android? How to go about this, if it’s a permission issue? In market place, most of the devices installing my app may not be "rooted"!!
Has anyone implemented new file system/drive using DokanNet on Android/Monodroid and faced with similar issues? Solutions???

When using a tool it's a good idea to have some basic understanding of how it works. Dokan works by installing Windows filesystem driver. On Android there's no concept of drives and mounting anything to the filesystem is not possible (without building custom kernel and installing it on device). Consequently your idea is DOA on Android and you need to look for other ways to deal with your data.

Related

Xamarin.Forms (UWP and Android) directory selection outside of AppData

I've been pulling my hair out all day. I'm converting my WPF app to Xamarin.Forms (UWP, IOS and Android). I'm currently focused on UWP and Android (don't have an apple devices yet) and I got a lot of the program running but I ran into a huge snag with reading files that are not in my sandbox directory. Currently, my app allows you to choose a folder with images and you can move through them. To test out the reading functionality, I've placed the images into the "LocalState" directory and bingo, my code is working beautifully. Now the program doesn't have a default folder and when I originally created it in WPF, the user would have a pop up and they would choose their own folder but I cannot for the life of me get a similar function for Xamarin. Every time I try something, I get an "access denied". I've seen Android apps allow you to pick a folder for emulators and I'm 100% sure that you can setup UWP to do permissions with StorageApplicationPermissions but I just cannot get this to work for Xamarin.Forms. Please help me!
OK, Android first it is easier. You need to setup in the manifest permissions to read and write SD-card. On Marshmallow and later you need to ask for the permission at the runtime (you need to do that from the native project).
On UWP the easiest thing to do would be to set the broadfileaccess in the manifest. Other than that you pointed out to the proper APIs, just you need to run them natively.
In general native code is called by using dependency injection. If it gets too complicated you may consider to create Xamarin.Forms project as a shared project where you can use conditional compiling instead of dependency injection which is quite simpler.

Qt android ndk - app crashes

I've been recently trying to make some very simple app in Qt, and yesterday it used to work correctly on both Desktop and Android (using android ndk, I know it's not good to make android apps in c++, but I just want to try).
Today, out of nowhere, application output says sth like this:
The only thing I've found was cleaning app's cache and data, restarting phone, rebuilding, none of these things worked
A Qt app has an array of used .so library names, somewhere in the resources.
On start-up, it loads all these .so libraries (via loadLibrary()).
The order in which the libraries are loaded is important: functions cannot
reference functions defined in libraries that have not yet been loaded. So implementing a circular dependency is tricky.
From the logs I see that
some function in libszachy_android_1.so (is it the right name? it's a bit strange) invokes srand() that has not yet been loaded; maybe, it is mentioned later in the load list, but loadLibrary() has no idea about the planned future.
Therefore, you get this.
If your code worked yesterday, you likely have made some changes. If you use version control, you likely can compare the today's and yesterday's versions and see the difference. Maybe, you have inserted a forward reference (in the load list sense). OTOH, sometimes both Eclipse and make cannot detect that the source has changed and make incorrect builds (I did observe this, but cannot reproduce). Did you try to uninstall the app from the phone? Did you try to remove all existing .so files in the build directories (rm *.so)?
Maybe, one of your .so modules is broken: sometimes an object is generated despite of errors and it may get used in subsequent builds (at least this is how I can explain the build glitches).
Maybe, you have no memory left on the device, and the .so could not be unpacked correctly.
I suggest examining the application directory with adb shell on a rooted device.
PS you posted a screenshot that is barely readable. Please replace it with the relevant portion of the adb logcat output (I hope you know how to use it; if not, the first thing to do is to learn adb logcat and adb shell).

How could you generate an APK from project B programmatically, using a button click from project A?

I have a project A that should use a wizard to create a project B. Project B is based on a template. Project A should send data to that template and generate an APK from this data and template programmatically.
I've read about the APK structure and what it includes, like classes, resources, and manifest files. My question is, what is the best way to achieve this template-based generation of an APK? What could I use for this?
This is the open source project you're looking for.
https://code.google.com/p/terminal-ide/
Terminal IDE is a command line java / android dev kit that runs on the device itself. Using a correctly configured vim, bash and busybox, in a custom terminal + custom keyboard environment. All these applications are put together so that they interact correctly. A full Terminal emulator + custom ANSI keyboard ensure good bash, vim and busybox emulation. All set up and ready to run in a NON-ROOT environment. Normal user permissions are enough to run all of this.
You can also download it from Google Play here. The application has 4.7 stars on the Play Store from 1,324 ratings. Here is one of the latest written 5 stars reviews this application received on Google Play. And it's not unique by any means (the emphasis in bold is mine).
A Google User - March 12, 2013 - Version 2.02
Wow!
I have over 30 years programming experience (mostly in C/C++ and Assembly) and have been looking to learn to program Android. I looked everywhere for a way to compile and run Java tutorials on my tablet, with no success, until I found Terminal IDE! Then I started playing around with its capabilities and let me say again, wow. DEVELOPER - I have only one suggestion, which others have brought up too: reduce the internal memory footprint. Maybe breakup the different languages into installable add-ons?
In a way, it's a lot like the Android Java IDE called AIDE, minus the GUI interface (but unlike AIDE, it's doesn't have low artificial file limits, and since it's open source it can actually be used to build your own project upon and extend).

Launch .apk file on Android device

Might seem a pleonasm the 'Title' but I wrote it to emphasize the issue.
I have an application running on an Android device, using the 2.2 Froyo library. The application has to (1) install - if not already installed - then (2) launch an .apk file already present in the data/data/myapp/files/ folder.
Knowing Java I would have used a shell execution of the above operations. But Android is also a separate namespace, therefore I would like to know how to do the sequence install + launch of the .apk file.
To note that, while I'm using Eclipse/Ubuntu now, the implementation should take into account ONLY the Android OS APIs, not my dev environment available tools.
Thanks
You do not launch an apk file. An apk file can be thought of as a container holding some number of activities, services, receivers, among other constructs. It's likely you mean you want to launch an activity (which is performed using the startActivity() method from the Context class, or one of its many subclasses) but by no means is that a certainty.
It would seem from your question that you need to learn quite a bit about Android before continuing on the path suggested by your question, because the question you've posted is really too vague to be answered in a reasonable manner for stackoverflow.

GUI-less programming for Android as if it were an ordinary Linux system

I need to do some menial batch tasks on my phone, and I don't want to jump through all the hoops of making an "app" with a GUI and all that just to do them (the tasks are of the type you'd hack together in BASH in five minutes on a sane system). I can't seem to find any place on the net that explains how to simply make an ordinary program (in any language, but Java is OK if that eases interaction with Android) with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process. No need for an APK package, no need for a GUI, no nothing. This should be the simplest thing in the world, but every example out there seems to be first and foremost concerned with making a GUI and working with Eclipse and the SDK instead of doing the basics first.
Any tips?
(I know this is probably borderline SuperUser, but then again, there's a programming question at the bottom: How do you make an ordinary (Java) program that can be run from the terminal on an Android phone and still use the API?)
Here : Running a shell script on android device using adb
and : https://play.google.com/store/apps/details?id=stericson.busybox&hl=en
and : http://forum.xda-developers.com/showthread.php?t=537827
and : http://strawp.net/archive/recipe-for-a-decent-bash-shell-in-android/
and : http://digitaldumptruck.jotabout.com/?p=938
I can't seem to find any place on the net that explains how to simply make an ordinary program (in any language, but Java is OK if that eases interaction with Android) with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process.
That's because it's not especially important to the bulk of Android users or developers.
How do you make an ordinary (Java) program that can be run from the terminal on an Android phone and still use the API?
You are welcome to use the Scripting Layer for Android to write some scripts, but you have limited access to the Android SDK, and they cannot "simply be run by SSHing into the phone". This is supported by the SL4A team.
You are welcome to experiment with the dalvikvm command, though off the top of my head I do not recall whether or not it is available on production devices, and I do not know if it can "simply be run by SSHing into the phone". And, bear in mind that using this is completely unsupported.
You are welcome to write your own C/C++ code for ARM (or whatever CPU architecture your device runs). This "simply be run by SSHing into the phone" but has no access to the Android SDK.
I still cannot believe that that kind of stuff isn't on the first page of every Android development introduction out there.
There are over 200 million users of Android devices. What percentage of those users do you think want to
"make an ordinary program... with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process"? 0.01%? 0.001%? My money is on 0.0001%.
The "first page of every Android development introduction out there" should be focused on stuff that matters to closer to 100% of the user base. You, of course, are welcome to build up your own site focused on this sort of thing, to cater to those users who are interested in creating these sorts of programs.
From http://git-annex.branchable.com/design/assistant/blog/day_184__just_wanna_run_something/:
While I already have Android "hello world" executables to try, I have
not yet been able to run them. Can't seem to find a directory I can
write to on the Asus Transformer, with a filesystem that supports the
+x bit. Do you really have to root Android just to run simple binaries? I'm crying inside.
It seems that the blessed Android NDK way would involve making a Java
app, that pulls in a shared library that contains the native code. For
haskell, the library will need to contain a C shim that, probably,
calls an entry point to the Haskell runtime system. Once running, it
can use the FFI to communicate back to the Java side, probably. The
good news is that CJ van den Berg, who already saved my bacon once by
developing ghc-android, tells me he's hard at work on that very thing.
and some specific advices in the comments below:
See http://kevinboone.net/android_nonroot.html for info on where in
the android filesystem you have write, exec ability.
Basically you have these abilities in /data/local from adb shell (and
in debuggable app's folders using run-as with adb shell), and in
/data/data// for each app (for example the terminal emulator's
data dir when using the terminal emulator).
...
http://git-annex.branchable.com/design/assistant/blog/day_185__android_liftoff/:
Thanks to hhm, who pointed me at KBOX, I have verified that I can
build haskell programs that work on Android.
http://kevinboone.net/kbox.html:
KBOX [...] gives you the terminal emulator, a
decent set of Linux utilities (supplied by busybox), ssh and rsync
clients and servers, and a few other things. In addition, there are a
number of add-on packages for expanded functionality.
Well, it's just about running an executable on Android, and not about writing an executable that would access Android API...
I can't seem to find any place on the net that explains how to simply make an ordinary program [...] with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process.
An answer, translated from a note by vitus-wagner:
Termux is an advanced terminal emulator plus lots of Unix-like software with command-line interface (in packages managed by APT). Actually, not only CLI (command-line), but also GUI as well (though the GUI software not tried yet).
Unlike the way of the various popular "linux deploy" (which make something like a container, at least a chroot, with things installed into directories according to the traditional filesystem hierarchy), Termux seems to aim at integrating into the host system. For this purpose, it has a plugin, Termux:api which is able to do a lot of interaction with the system: open a file in a native Android app, send an sms, take a picture with the camera, or even say something by means of the system TTS engine.
There are many more addons -- see wiki.
(A side note. An integration like that could be expected--if not from MSYS--from GnuWin32, but there is nothing close to Termux under Windows w.r.t. the degree of integration.
However, for some strange reason, people are asking much more about how to make it more "Linux-like" on the forum, rather than how to use it effectively to solve smartphone-specific tasks...)
A toolkit for cross-compilation is available, so that one can try to package his favorite software.
Actually, it is able to do compilation locally on the device, but it seems not to be able to make a package locally.
Some things to know:
One needs Hacker's keyboard or something similar. One can't live here without Esc, Tab, Control. Or one could try to learn the Touch Keyboard.
vim ran with an encoding different from utf-8, and the Russian letters were displayed incorrectly. So, set encoding=utf-8 had to be written in .vimrc.
ssh to another computer at home couldn't login. The reason was simple: it used the username u0_a95 instead of one's usual username. (One can write User your_username in .ssh/config to permanently "fix" it.)
I'd recommend doing a research on XDA-Developers board

Categories

Resources