Hey there guys
I'm having a little problem with using trigonometric functions in my code. Here's the plot:
-I've imported java.lang.Math
-Then i'm using the functions in my statement as:
double a = sin(dLat/2) * sin(dLat/2) + cos(toRadians(lat)) * cos(toRadians(lat1)) * sin(dLon/2) * sin(dLon/2);
-But it gives the following errors during build:
The method sin(double) is undefined for the type testmap
The method toRadians(double) is undefined for the type testmap
where testmap is my package name
I'm using eclipse IDE.
Please help me out!
Regards
Umer Aziz Malik
Math..sin(), Math.toRadians() and so on.
That are static methods of Math class, not members of your class (testmap?).
Oh how did i miss that
Thanx a lot mate
Related
hi,
is there any way to set the sim pin by my applikation?
we don't want our customers to know the sim pin, so our applikation will know it (encrypted config file). if the device needs the sim pin, it shouldn't prompt the user for a sim pin. my application should set it for the user.
Maybe the following code would be helpful for you:
Code:
TelephonyManager tm =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(tm.getClass().getName());
Method m = clazz.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony it = (ITelephony) m.invoke(tm);
it.supplyPin("1111");
Please keep in mind that you also need ITelephony.aidl from Android sources.
rwxer said:
Maybe the following code would be helpful for you:
Code:
TelephonyManager tm =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(tm.getClass().getName());
Method m = clazz.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony it = (ITelephony) m.invoke(tm);
it.supplyPin("1111");
Please keep in mind that you also need ITelephony.aidl from Android sources.
Click to expand...
Click to collapse
thank you very much.
can you please tell me, where to get the right ITelephony.aidl? i tried searching in my sdk folder, but didn't found anything. google found a couple of different versions. what should i do exactly with the aidl file?
bassmaster said:
thank you very much.
can you please tell me, where to get the right ITelephony.aidl? i tried searching in my sdk folder, but didn't found anything. google found a couple of different versions.
Click to expand...
Click to collapse
I used aidl from source repository http://android.git.kernel.org/ , version 2.2. You can try the one you found.
bassmaster said:
what should i do exactly with the aidl file?
Click to expand...
Click to collapse
Did you try to google?
http://developer.android.com/guide/developing/tools/aidl.html
Place ITelephony.aidl in package com.android.internal.telephony in your source dir. After that java classes should be generated from .aidl files and compiled if you're using standard build script.
I added “ITelephony.aidl” and the code to my app. It all works fine. Thank you.
But now I have the following problem:
My App starts within the device. While booting, the sim pin dialog request appears. This screen is blocking everything - including the start of my app.
How can I avoid that?
The only workaround known to me is to do the following:
I enabled the flight mode before I shut down the device. After reboot my app starts, disables the flight mode and sets the pin.
But I don't know an efficient way that always starts the device in flight mode.
Can you help me please?
You can try to handle android.intent.action.BOOT_COMPLETED intent (see example http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/) and provide sim pin code just after boot. Don't forget to add permission android.permission.RECEIVE_BOOT_COMPLETED
Hi There Everybody ! I am Seaskyways and I am back with a surprise ! My Android Java Class "Shells" !
App Devs ! Shells Java Class
My Java class Shells is a class to simplify the use of sending normal commands (Shell Commands) and capturing their output ! The Reason its called Shells because it is not a single shell , its not only two or three methods , its a wide variety of methods that helps you complete your wanting easily ! Whoever , it is not totally stable and I need some help from app / java devs to fix some Exceptions , please anybody who knows contact me . The functions and uses of the class will be provided gradually in this thread (because I will have my term tests nearly) .... I might be updating this class about weekly , because I am busy , sorry
This Class will provide mainly a root shell for rooted devices , and a non-root shell for non-rooted devices , and free single command sending which returns the output , more info down
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Functions (Methods):
Start(): public void , returns nothing , used to start both the Root shell and Non-root Shell.
Stop(): public void , returns nothing , used to stop both the Root shell and Non-root Shell , plus it resets the variables used in those shells.
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Logsh(): public String , returns a String showing all the output of the commands sent using the Non-root shell , may cause the Non-root shell to stop , if an error occurs , please call Start() before using it . (please help here a small bug)
Logsu(): public String , returns a String showing all the output of the commands sent using the Root shell , may cause the Root shell to stop , if an error occurs , please call Start() before using it . (please help here a small bug)
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Readsh(): public String , returns a String showing the last command's output sent using the Non-Root shell , may cause the Non-root shell to stop , if an error occurs , please call Start() before using it .
Readsu(): public String , returns a String showing the last command's output sent using the Root shell , may cause the Root shell to stop , if an error occurs , please call Start() before using it .
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
su(String): public void , returns nothing , this is the Root shell, it executes the command given as root , it is used in the following form
Code:
Start();
su("My command");
sh(String): public void , returns nothing , this is the Non-Root shell, it executes the command given as normal user , it is used in the following form
Code:
Start();
sh("My command");
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
su(String[]): public void , returns nothing , this is the Root shell,it converts the array to a String then it executes the command given as root , it is used in the following form
Code:
Start();
su("My", "command");
sh(String[]): public void , returns nothing , this is the Non-Root shell,it converts the array to a String then it executes the command given as normal user , it is used in the following form
Code:
Start();
sh("My", "command");
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Shells(); public static Shells , it returns new Shells()
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Download Dev-host
More Explanations coming later
Reserved in case needed !
Looks usable!
Sent from my Galaxy Nexus running Android 4.2 JB
Its Very usable , but I need help in fixing it ! Plus I tried posting this on the portal , but seemed uninteresting to XDA
seaskyways said:
Its Very usable , but I need help in fixing it ! Plus I tried posting this on the portal , but seemed uninteresting to XDA
Click to expand...
Click to collapse
This is almost a year old, but this looks like exactly what I need! Seems the link is down Can you PM me or reply ? If you have time of course.
Hi everybody,
It's my first post on XDA, because I always got my answer on the differents topics I found.
I'm actually working on monitoring network. I use the firmware provide by these brillant guys :
http bcmon blogspot ie/.
I want to developp an native code to write a easy airodump-ng like, to monitoring the traffic close to my device.
I need to use radiotap headers to do what I want, and of course a monitoring access to my wireless card.
So I reverse the bcmon.apk provided by bcmon team, to look how they lauch airodump-ng in a term. I noticed they use LD_SHARED=`pwd`/libs LD_PRELOAD=`pwd`/fakedriver.so.
My first problems : my toolchain (provided by NDK) don't have radiotap header access, and I really don't know how to add these last one to it.
My second problems : how to compile my code with the LD_SHARED/ LD_PRELOAD libraries used by bcmon drivers to ensure I'll be able to execute my code with the monitor mode activated. I think that I will have to add the libs contained on /data/data/com.bcmon.bcmon/files/libs
on these of my toolchains, but I really don't know.
I read a lot papers to understand how linking works in C, but I'm probably still missing something.
I really don't know how to improve my toolchain, and I'm quite anoyed because I haven't progressed in my work for days...
Any help will be really appreciated.
Thanks a Million
Ant.
I found a solution few weeks ago.
I had linking erros.
I reserved the .apk provided by bcmon guys.
For those that want to develop using monitoring functionnalities, there is the way to do :
LD_PRELOAD=/data/data/com.bcmon.bcmon/files/libs/libfake_driver.so LD_LIBRARY_PATH=/data/data/com.bcmon.bcmon/files/libs ./yourprog
If you want to comiple your code using some of their libraries, for example pcap libraries I have done the fellowing stuffs :
1- found radiotap headers, and pcap headers on github likes websites.
2- try to cross compile with the headers
3- Correct the erros (like typedef missing ...)
4- Build your make file adding name of the libraries :
GCC={your toolchain}
FLAGS={your flags}
LIBS=libfake_driver.so \
libpacap.so.1
OBJ = {your obj}
output :
$(GCC) $(OBJ) -c {yoursrcfile) -o {output} $(FLAGS) $(LIBS)
Hope it 'll help.
Ant.
So, I am currently messing around with android programming, and i am using android studio and my ide of choice. I have made a few simple apps(calculator and whatnot) without issue. But now i am trying to make an app using the youtube data api. I can not even get started on it though because i cant get the api to work. Heres what i have done so far.
I have taken the api zip file and unzipped it. This produced an youtube folder. I than copied this folder to the libs folder in my project. This caused no issues in and of itself.
I than tried to add some imports based on the api and that caused an syntax error
To fix that error i added the following lines to the build.gradle in the dependencies section at the bottom
Code:
compile fileTree(dir: 'libs/youtube', include: '*.jar')
compile fileTree(dir: 'libs/youtube/libs', include: '*.jar')
This fixed the syntax errors and also allowed it to build successfully
The issue comes when I try to actually add something based on the api. When i add the following lines of code...
Code:
/** Global instance of the HTTP transport. */
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
/** Global instance of the JSON factory. */
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
/** Global instance of Youtube object to make all API requests. */
private static YouTube youtube;
there are no syntax errors, but when i attempt to build it I get a single error
Code:
Gradle: Execution failed for task ':ApiTest2:dexDebug'.
> Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.2.2/dx --dex --output /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/build/libs/ApiTest2-debug.dex /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/build/classes/debug /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/build/dependency-cache/debug /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-servlet-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-oauth-client-servlet-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-protobuf-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-http-client-jdo-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/google-api-services-youtube-v3-rev70-1.16.0-rc-sources.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/transaction-api-1.1.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-http-client-appengine-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/jackson-core-asl-1.9.11.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/protobuf-java-2.4.1.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/httpclient-4.0.1.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-oauth-client-java6-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/gson-2.1.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-http-client-gson-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/commons-logging-1.1.1.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-http-client-android-1.16.0-rc.jar /Applications/Android Studio.app/sdk/extras/android/m2repository/com/android/support/support-v4/13.0.0/support-v4-13.0.0.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/jackson-core-2.1.3.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-gson-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/google-api-services-youtube-v3-rev70-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-oauth-client-java7-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-android-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/jetty-util-6.1.26.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-http-client-jackson-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/httpcore-4.0.1.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/jetty-6.1.26.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-oauth-client-jetty-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-oauth-client-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/jdo2-api-2.3-eb.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-oauth-client-appengine-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-http-client-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/google-api-services-youtube-v3-rev70-1.16.0-rc-javadoc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/jsr305-1.3.9.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-appengine-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-java6-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/xpp3-1.1.4c.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-http-client-jackson2-1.16.0-rc.jar /Users/Andrew/AndroidStudioProjects/ApiTest2Project/ApiTest2/libs/youtube/libs/google-api-client-jackson2-1.16.0-rc.jar
Error Code:
1
Output:
trouble processing "javax/transaction/HeuristicCommitException.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
And i am not sure why this is happening. I am sure I am doing something wrong, but I havent found anywhere online where i shows how to do this exactly and through all my tinkering i havent gotten it to woerk.
Any help
Anyone have any ideas? Over 100 views and no replies
Hi,
although I haven't face the same problem, I think I can analyze your problem.
It's because dependencies in your gradle.build
You can't declare 2 "compile"(s) statement like what you've done.
Code:
compile fileTree(dir: 'libs/youtube', include: '*.jar')
compile fileTree(dir: 'libs/youtube/libs', include: '*.jar')
That's wrong, though I don't know how to solve that given that I'm still learning about it.
I thought that these links can help you solve it:
- http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
- http://www.gradle.org/docs/current/userguide/dependency_management.html
JoshieGeek said:
Hi,
although I haven't face the same problem, I think I can analyze your problem.
It's because dependencies in your gradle.build
You can't declare 2 "compile"(s) statement like what you've done.
Code:
compile fileTree(dir: 'libs/youtube', include: '*.jar')
compile fileTree(dir: 'libs/youtube/libs', include: '*.jar')
That's wrong, though I don't know how to solve that given that I'm still learning about it.
I thought that these links can help you solve it:
- http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
- http://www.gradle.org/docs/current/userguide/dependency_management.html
Click to expand...
Click to collapse
curious if either one of you figured it out.
If you are trying to use youtube api add the following line to the gradle build.
Code:
compile 'com.google.apis:google-api-services-youtube:v3-rev107-1.18.0-rc'
You dont need to download and copy the youtube project into your project.
AndroPy
a python3 library to communicate with your phone
INTRODUCTION
Hey there! In relation to THIS library written in JAVA :silly: I decided to write another library in Python3.
I try to reach the same functionality as that JAVA lib and maybe even more. "Why Python3?" you may ask..
Because it's the language I love the most, it's platform-independent and has got a beautiful syntax.
It's in early stage and there are only some functions working right now which I will explain in another block.
Click to expand...
Click to collapse
FEATURES
Install ADB-binary (only working on linux 64-bit for now)
Reboot (system, recovery, bootloader)
Execute shell commands and get output-lines as a list
Get list of connected devices
Get build.prop as a dictionary
Click to expand...
Click to collapse
EXAMPLES
I included a function called example wich will be automatically executed if you run adb_util.py.
It shows what you can do with that library. The installer isn't fully working yet, only in Linux 64bit systems.
In order to use adb_util.py the adb-binary has to be in ~/.andropy/bin.
Click to expand...
Click to collapse
Install adb via installer.py on Linux 64-bit machines
Just execute it like:
Code:
python3 installer.py
Click to expand...
Click to collapse
Show content of /sdcard
Code:
import andropy
with andropy.ADBInterface() as ai:
print(ai.exec_shell_cmd("ls /sdcard/"))
Get screen-resolution
Code:
import andropy
with andropy.ADBInterface() as ai:
build_props = ai.get_build_props()
print(build_props['ro.device.screen_res'])
Samle output from adb_util.py
Code:
[email protected]:~/src/andropy$ python3 adb_util.py
# Welcome to AndroPy #
----------------------
Number of devices detected: 1
Number of your downloaded apps: 41
Your phone's CPU: 1.7 GHz quad-core
Your phone's model: HTC m7ul
SOURCE
https://github.com/tehmk/andropy
But as I mentioned it isn't nearly ready yet. Some of you maybe know how to use it in this state.
I will add features and more detailed instructions step by step.
Click to expand...
Click to collapse
hey saw this pop up in the portal. after a quick glance this can become a good concept for users, such as timed logs, or a function to dump information (build prop, kmsg, logcat, bugreport, tombstones, you get the idea)
I'd like to bring your attention to this though. the prop parser
Code:
def get_build_props(self):
build_props = {}
out = subprocess.check_output([ADB_EXE, "shell",
"cat /system/build.prop"],
universal_newlines=True)
self.check_output(out)
for line in out.split('\n'):
if line == '':
continue
prop = line.split('=')
if not prop[0].startswith('#'):
build_props[prop[0]] = prop[1]
return build_props
you don't need to fetch the whole build prop (for most of the time). this is an extra function that you can use
Code:
def get_prop(self, prop):
out = subprocess.check_output([ADB_EXE, "shell",
"getprop", "{}".format(prop)])
self.check_output(out)
return out
if you need any other help or tips, feel free to ping me on freenode, or drop a message here
This is great. Thank you. Will be using and might contribute.
Seems like I've started a trend here. Lol
Beatsleigher said:
Seems like I've started a trend here. Lol
Click to expand...
Click to collapse
seems so. I've got the base layer of a python package that plugs directly into the adb server. none of these wrappers needed