[android-developers] Re: New project with online database
I would certainly look at Retrofit2 library for doing any kind of http transaction ( http://square.github.io/retrofit/ ). You can find simple example using this library at https://github.com/snijsure/tinyurl For general callback stuff you should also make yourself familiar with RxAndroid ( https://github.com/ReactiveX/RxAndroid ) but it might be bit tough get your arms around it. Again you can find simple example of using RxAndroid to handle callback at https://github.com/snijsure/TwitterSample Hope this helps. -Subodh On Saturday, March 19, 2016 at 1:08:54 PM UTC-7, Anwar Saiah wrote: > > I'm working on an app that should retreive some data from a web stored > database. Then this data will be maintained manipulated and such.. > I thought that it would best if I built a java class in my android project > to hold an object(Student) that will hold the data. > Then another class Students that will have a linked list of students and a > http post request object that will retreive the data. Now before I get into > anymore detail, is this a good practice? You see inside this Students class > I have to create a new thread that will do the networking and store data > into the list before displaying it on the UI. > What is best if so to use for retreiving the info to the list from the > thread? ThreadHandler, Thread, AsyncTask ? > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/e3c8d988-f208-4535-9ded-1dd09dafe117%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Using android:action to launch activity from settings
I have defined my settings.xml file to include an item that uses android:action item in the setting dialog. See the sample code for that activity below. It all works fine. However this thing is "overlaying" my entire activity and when user presses back button my entire application finishes. Is there a way to launch a "Fragment" using android:action in settings.xml or how I can restructure my activity so when that activity finishes my main activity is resumed? here is the activity code public class ShowCurrentUserActivity extends Activity { public AlertDialog dialog = null; @Override public void onCreate(Bundle savedInstanceState) { String msgStr; super.onCreate(savedInstanceState); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setPositiveButton("Logout", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); ShowCurrentUserActivity.this.finish(); } }); alert.setNegativeButton("Dismiss", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); ShowCurrentUserActivity.this.finish(); } }); } } This is how I specify activity in my AndroidManifest.xml -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] How to prevent application install that are not signed by certs in "approved list"
Hello, On my OEM device we have custom launcher that only displays launch icons for APKs that are signed by list of specific keys. Is there a way to register broadcast receiver for PACKAGE_ADDED and then check signature of the APK and allow installation to proceed or fail it? -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[android-developers] How do I start adb on rooted device from Android application?
I have rooted phone on which I want to enable disable adb from program, without having to modify native system.settings application. So I have small Android application that executes commands as root: stop adbd setprop service.adb.root 0" adbd usb start adbd But when I connect to the device by USB cable my laptop doesn't see devices? Is there something else I need to start/stop adb daemon so I can connect it over usb cable? However I can alway reliably start adb daemon on my device so I can connect to it via tcp i.e. following works each time. setprop service.adb.tcp.port stop adbd setprop service.adb.root 0 start adbd ( I am having to do all this song-and-dance because on this device we want only certain application/user to be able to connect to device over adb , we don't ship this device with standard settings application ) -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [android-developers] Re: Any good guide lines for using TAG when using Log. statements
But I wanted to run something outside the eclipse. Something like adb logcat | grep -i 'packagename' or adb logcat | grep -i companyname from command line. -Subodh On Tue, Apr 30, 2013 at 2:04 PM, lbendlin wrote: > Adding the company name is not necessary as the Eclipse debug widget already > gives you the option to filter by your app. > > > On Tuesday, April 30, 2013 2:02:41 PM UTC-4, Subodh Nijsure wrote: >> >> I am wondering if there any good practices that people have come up >> when it comes to defining TAG prefix for large android applications. >> So one can easily filter your application logs. >> >> Currently all my code uses: >> >> final String TAG = MyClassName.class.getSimpleName(); >> >> We have just recently moved to adding our company prefix to the TAG so >> we can only see log messages to our own application. >> >> i.e. >> >> final String TAG = GlobalConst.companyName + >> MyClassName.class.getSimpleName(); >> >> Are there any other techniques people have used to define TAG for log.X()? >> >> -Subodh > > -- > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to android-developers+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[android-developers] Any good guide lines for using TAG when using Log. statements
I am wondering if there any good practices that people have come up when it comes to defining TAG prefix for large android applications. So one can easily filter your application logs. Currently all my code uses: final String TAG = MyClassName.class.getSimpleName(); We have just recently moved to adding our company prefix to the TAG so we can only see log messages to our own application. i.e. final String TAG = GlobalConst.companyName + MyClassName.class.getSimpleName(); Are there any other techniques people have used to define TAG for log.X()? -Subodh -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[android-developers] Is there good source for Themes for Android applications
Yes, I have done google search on Android Theme collection and haven't come across anything impressive. Is there a good collection of web sites where one can purchase/connect with folks who do theme design for Android? -Subodh Nijsure -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [android-developers] Re: How do you show 'Are you sure you want to quit' dialog?
I had no idea I would spark such a discussion. Only reason I was considering adding 'are you sure you want to exit' button was Some of my screens have 5-8 items that users enter stuff like name, address, some other data. I just don't want users to enter say 80% of data and loose that data just because they hit back button one two many times.. Is there another UI pattern one should follow in that case? [ Something like what gmail does regarding auto-saving your draft messages, but do that in android app.. ] -Subodh On Wed, Nov 28, 2012 at 10:09 AM, Kristopher Micinski < krismicin...@gmail.com> wrote: > To add, the "exit" button also has the effect of turning off GPS updates, > so "exiting" also has a feature that implies something else: that you quit > draining the user's battery. > > > On Wed, Nov 28, 2012 at 12:38 PM, Latimerius wrote: > >> On Wed, Nov 28, 2012 at 6:24 PM, TreKing wrote: >> > On Wed, Nov 28, 2012 at 11:18 AM, TreKing wrote: >> >> >> >> On Wed, Nov 28, 2012 at 11:02 AM, Latimerius >> wrote: >> >>> >> >>> Yeah, well, it's probably not by Google, or one that Google had any >> >>> say in. None of the built-in apps on my devices have an exit button, >> >>> not even games (that in general do include it AFAICT). >> >> >> >> >> >> Google Maps Navigation has "Exit Navigation" as an option in the menu >> (at >> >> least on my device running 2.3.4). >> > >> > >> > Oh, and in reference to the original point of this thread, if you press >> > back, it asks you "Exit Navigation? This will end all route guidance". >> If >> > this check wasn't there, and you exited the app accidentally, you would >> have >> > to re-enter the app and re-input your route guidance parameters and >> restart >> > the process, which would be a pain in the ass if you're in the middle of >> > driving. So seems like there are some valid use cases for such >> validation. >> >> Interesting, thanks for pointing this out. I'm guessing something >> about Navigation must be somehow expensive or slow so they had to put >> that check in. Or otherwise, was the crusade against exit buttons I >> remember seeing all over the net back in 2009/2010 misguided? >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How do you show 'Are you sure you want to quit' dialog?
Hi, I want to present a yes/no dialog when user enters back, on main activity 'are you sure you want to quit? ' And if they click ok, quit the application. To do this I show a dialog in onDestroy() that asks yes/no question but that doesn't work. What is correct way to implement 'are you sure you want to quit the application' dialog? -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: android SQLite
On Fri, Oct 26, 2012 at 2:23 AM, Tim wrote: > Dear Nageswararao, > > Could I suggest you have a look at the MobiForms Advanced Edition mobile > development suite for Android? > Can we keep the marketing stuff off the mailing list? You can always reply directly to person who requested information? -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] start service from service
On Wed, Oct 24, 2012 at 12:46 AM, Live Happy wrote: > I have a service in my application but this service stop working after time > and i want to keep the service keep working without stopping and for that i > try to start the same service from onDestroy method when it dieing but its > not work even the written log not appear ,so it is possible to call the > service from itself and if it not may i create another service who do the > same work and they call each other when one of them stopped, so when in > onDestory i cant call it so how to call it?, wish that someone can help me > with this situation thx on advance Have you tried returning START_STICKY in onStartCommand() of the service. It is supposed to keep the service running till user explicitly stops the service. Ref: http://developer.android.com/reference/android/app/Service.html#onStartCommand%28android.content.Intent,%20int,%20int%29 -Subodh > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Does content provider run in its own process space?
On Wed, Oct 24, 2012 at 11:45 AM, Mark Murphy wrote: > On Wed, Oct 24, 2012 at 2:36 PM, Subodh Nijsure > wrote: >> We don't want this upload process to happen in context of UI hence >> the service. > > Please use a single process, and simply have the upload work be done > in a background thread. I guess then I am confused on if "sync" thread terminates if the UI activity is destroyed or not. What I want to happen is this background thread that syncs data to aws should never terminate,and ideally it should get started when device boot finishes i.e. data collected while there was no network connectivity, should get uploaded to AWS without user having to do it explicitly. I do start my service such that it returns START_STICKY in its onStartCommand(), is that sufficient for the service to keep running even if activity is destroyed? > >> I read the commons ware book (page 459 to be specific) and the >> database instance that content provider uses singleton database object >> based off of getActivity().getApplicationContext(). > > Page 459 does not say this. > > It says that you need to use a single SQLiteDatabase object if you > want SQLiteDatabase to help with thread safety. Page 459 does not > address ContentProvider at all. > Yes it does not mention CP, didn't mean to imply it did. >> Now the question is -- what happens if the service (3) is using the >> content provider and user starts the UI (1) that also attempts to use >> the same content provider, is the UI going to experience issue opening >> the database, is it going to encounter ANR? > > Possibly. SQLite implements process-level locking -- you use it all > the time from, say, Ruby. I have not played with its effects on > Android, as I don't waste the user's RAM and CPU with extra processes. > >> Put other way, does the content provider run in its own process? > > It runs in the process that the rest of your components run in, normally. > >> And >> are requests & responses to content provider serialized? > > I do not think so, but I have been confused on this particular point before. > > -- I am going to try and model this (best I can) but I just wanted to get expert opinion to see if its worthwhile -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Does content provider run in its own process space?
Hello, I will briefly describe application I am writing. 1. Application is used in environment where phone/tablet may not have network connectivity, person is collecting some data using the app on the device. 2. This collected data is stored using a content provider, that uses sqlite database (SQLiteCursorLoader from CommonsWare book) and this content provider is part of library. 3. There is background service that is gets started when upon boot completed notification, and it waits for network connectivity broadcast. Once the device has network connection, it retrieves the data using the content provider in step 2. This service uploads the collected data to amazon cloud service. We don't want this upload process to happen in context of UI hence the service. I read the commons ware book (page 459 to be specific) and the database instance that content provider uses singleton database object based off of getActivity().getApplicationContext(). Now the question is -- what happens if the service (3) is using the content provider and user starts the UI (1) that also attempts to use the same content provider, is the UI going to experience issue opening the database, is it going to encounter ANR? Put other way, does the content provider run in its own process? And are requests & responses to content provider serialized? If there is good description of multiple clients using a content provider (simultaneously) and issues involved would appreciate pointer to that. -Subodh Nijsure -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] serial number?
Might want to search for ANDROID_ID in the document it is supposed to give unique id Subodh On Oct 12, 2012 8:24 AM, "bob" wrote: > Does every Android tablet have a serial number or some kind of unique > identifier? > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Android Module markets
On Fri, Oct 5, 2012 at 3:16 PM, Jeremy Villalobos wrote: > > I am interested in promotiong the idea of a geographically distributed, > lightly coupled idependent programmer groups somewhat specialized. I reach > the end of what Google could tell me and I wonder if somebody can send me in > the right direction, if projects around this idea already exists ? > > Thanks Have you looked at elance.com you can post your project requirements and someone can provide a bid for the work and take things from there. -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Unable to register CONNECTIVITY_ACTION in a service
Hello Robert, Below is the stack trace that I see when system catches the exception: Not sure if you had any chance glancing at my sample code on original email, and see if anything obviously wrong there? I/System.out(12738): java.lang.NullPointerException I/System.out(12738):at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:341) I/System.out(12738):at com.mycompany.ScsService.ScsService.(ScsService.java:50) I/System.out(12738):at java.lang.Class.newInstanceImpl(Native Method) I/System.out(12738):at java.lang.Class.newInstance(Class.java:1319) I/System.out(12738):at android.app.ActivityThread.handleCreateService(ActivityThread.java:2234) I/System.out(12738):at android.app.ActivityThread.access$1600(ActivityThread.java:123) I/System.out(12738):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201) I/System.out(12738):at android.os.Handler.dispatchMessage(Handler.java:99) I/System.out(12738):at android.os.Looper.loop(Looper.java:137) I/System.out(12738):at android.app.ActivityThread.main(ActivityThread.java:4424) I/System.out(12738):at java.lang.reflect.Method.invokeNative(Native Method) I/System.out(12738):at java.lang.reflect.Method.invoke(Method.java:511) I/System.out(12738):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) I/System.out(12738):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) I/System.out(12738):at dalvik.system.NativeStart.main(Native Method) -Subodh On Wed, Oct 3, 2012 at 7:39 AM, Robert Greenwalt wrote: > Checking network types explicitly like this is bad - what happens if the > device is connected through a bluetooth tether or via ethernet adapter? > > You could use getActiveNetworkInfo() and check it's connection, but this is > still polling. If you need to get notified when a connection comes or goes > (have something to do on next connect, for example) The CONNECTIVITY_ACTION > broadcast intent is the way to go. Note that this can be chatty - there are > several secondary networks that currently cause this broadcast that you may > have to weed out. You should use getActiveNetworkInfo in your handler to > find the state that applies to you. > > Can you post the stack trace of the NPE? > > R > > > On Wed, Oct 3, 2012 at 5:46 AM, Rahul Kaushik > wrote: >> >> hi subodh >> >> try this >> >> package com.FranConnectMobile; >> >> import java.io.BufferedReader; >> import java.io.InputStreamReader; >> import java.net.URL; >> import android.app.Activity; >> import android.content.Context; >> import android.net.ConnectivityManager; >> >> >> >> >> public class chkInternet extends Activity >> { >> public boolean isInternetAvailable(Context context){ >> ConnectivityManager connec = (ConnectivityManager) >> context.getSystemService(Context.CONNECTIVITY_SERVICE); >> android.net.NetworkInfo wifi = >> connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI); >> android.net.NetworkInfo mobile = >> connec.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); >> >> if(wifi.isConnected() || mobile.isConnected()){ >> // Check for web site >> try{ >> // Create a URL for the desired page >> URL url = new URL("http://www.google.com";); >> // Read all the text returned by the server >> BufferedReader in = new BufferedReader(new >> InputStreamReader(url.openStream())); >> in.close(); >> return true; >> } catch (Exception e) { >> return false; >> } >> } >> >> return false; >> } >> >> } >> >> TX >> RK >> >> On Wed, Oct 3, 2012 at 6:08 PM, Subodh Nijsure >> wrote: >>> >>> Hello, >>> >>> I am trying to implement a service that is supposed to download stuff >>> from a cloud service. So I want this service to be notified whenever >>> phone/tablet looses network connectivity. >>> >>> >>> So I implemented code that looks like this: >>> >>> receiver = new ConnectivityReceiver(); >>> filter = new IntentFilter(); >>> >>> filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); >>> try { >>> Intent i = registerReceiver(receiver, >>> filter); >>> } >>> catch (Exception e) { >>>
[android-developers] Unable to register CONNECTIVITY_ACTION in a service
Hello, I am trying to implement a service that is supposed to download stuff from a cloud service. So I want this service to be notified whenever phone/tablet looses network connectivity. So I implemented code that looks like this: receiver = new ConnectivityReceiver(); filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); try { Intent i = registerReceiver(receiver, filter); } catch (Exception e) { } However when I have this code in a class that extends a Service registerReciver always throws a NullPointerException. However the same code in a class that extends an activity does not throw such an exception. I have attached my manifest file and the full code for the service template. Would appreciate any pointers as to why this works in activity and not in a service. Or is there any better way for a service that run in the background to know when device looses/gains (IP) network connectivity? Regards, -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en AndroidManifest.xml Description: XML document package com.mycompany.ScsService; import android.app.Activity; import android.app.Service; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Messenger; import android.os.StrictMode; import android.util.Log; import android.os.Process; import java.lang.String; import java.lang.Exception; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.content.BroadcastReceiver; import android.content.IntentFilter; import android.content.Context; public class ScsService extends Service { private final static String LOG_TAG = ScsService.class.getCanonicalName(); private ConnectivityReceiver receiver = null; private int result = Activity.RESULT_OK; // Used to receive messages from the Activity final Messenger inMessenger = new Messenger(new IncomingHandler()); // Use to send message to the Activity private Messenger outMessenger; private IntentFilter filter = null; public ScsService() { super(); Log.d(LOG_TAG, new Exception().getStackTrace()[0].getMethodName() + " called"); // Don't do this // Network Stuff will run in the main thread StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder() .permitAll().build(); StrictMode.setThreadPolicy(policy); receiver = new ConnectivityReceiver(); filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); if (receiver != null && filter != null) { try { Intent i = registerReceiver(receiver, filter); if ( i == null ) Log.d(LOG_TAG,"Register received returned null"); else Log.d(LOG_TAG,"Register receiver returned non-null"); } catch (Exception e) { Log.d(LOG_TAG,"Exception while registering receiver => " + e); } } else { receiver = null; Log.d(LOG_TAG,"Receiver is not registered."); } } class IncomingHandler extends Handler { @Override public void handleMessage(Message msg) { Bundle data = msg.getData(); String message = data.getString(MessageConstants.MESSAGE); String str = "Message id is " + msg.what + " Actual message " + message + " "; Log.e("MESSAGE", str); Message backMsg = Message.obtain(); backMsg.arg1 = result; Bundle bundle = new Bundle(); str = str + " Service PID " + Process.myPid(); bundle.putString(MessageConstants.RETURN_MESSAGE, str); backMsg.setData(bundle); try { outMessenger.send(backMsg); } catch (android.os.RemoteException e1) { Log.w(getClass().getName(), "Exception sending message", e1); } } } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(LOG_TAG, new Exception().getStackTrace()[0].getMethodName() + " called for ScsService "); // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; } @Override public void onDestroy() { Log.d(LOG_TAG, new Exception().getStackTrace()[0].getMethodName() + " @ScsService called"); if ( receiver != null ) unregisterReceiver(receiver); } @Override public void onRebind(Intent intent) { Log.d(LOG_TAG, new Exception().getStackTrace()[0].getMethodName() + " @ScsService called"); } @Override public boolean onUnbind(Intent intent) { Log.d(LOG_TAG, new Exception().getStackTrace()[0].getMethodName() + " @ScsService called");
[android-developers] Errors while compiling latest Apidemos
This morning, I downloaded the latest Android 4.1(API 16) and also updated my eclipse plugins. I am trying to compile the ApiDemos and getting errors: AccessibilityNodeProvider cannot be resolved to a type AccessibilityNodeProviderActivity.java /com.example.android.apis.ApiDemos/src/com/example/android/apis/accessibility line 88 Java Problem ActivityOptions cannot be resolved Animation.java /com.example.android.apis.ApiDemos/src/com/example/android/apis/app line 98 Java Problem I followed the README.txt in ApiDemos and copied ./sdk/extras/android/support/v4/android-support-v4.jar to sdk/samples/android-16/ApiDemos/libs/. I updated the ApiDemos as additional jar and I am still getting these errors or I have looked over something basic/obvious in setting up the API16? -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Is it possible to pre-assign permission for specific USB device?
I have an application that talks to external USB device with vendor id of say 0xD00D and product id of 0x01. Is it possible to specify in AndroidManifest.xml file that my application should always have permission to use device with ID 0xD00D:0x01 without user having to explicitly give this permission when application starts? Currently I have declared following in my manifest, android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" and I have registered receiver for intent ACTION_USB_PERMISSION etc. as described in http://developer.android.com/guide/topics/connectivity/usb/accessory.html But is there any way to declare that my application X should always have permission for specific device, without user having to grant such a permission explicitly? -Subodh -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en