Android :: Difference Between Manifest And Programmatic Registering Of BroadcastReceiver

Sep 6, 2010

I am trying to understand the main differences between registering a BroadcastReceiver in the Manifest and registering it programmatically...

My understanding is basically as follows - would appreciate someone correcting my points if I am missing something.

Registered in Manifest:
- The OS will magically find and instantiate your class if needed, calling the onReceive() method, regardless what the running state of your application was
- Your receive will only get called once per broadcast (i.e. You can consider that registering in the manifest is like registering your 'class' for receiving the broadcast - and the broadcast instantiates your class as needed) (??)

Registered Programmatically:
- registering in code means that you are registering instances of your class to receive broadcast messages (i.e. if your code is a little sloppy, and you manage to register several times, you will end up with multiple BroadcastReceiver instances all having their onReceive() called for a broadcast
- to deregister, you need to deregister the specific BroadcastReceiver instance that you previously registered
- if your application gets destroyed by the OS, your onReceive() method will not be called for a broadcast

Android :: difference between Manifest and Programmatic registering of BroadcastReceiver


Android :: ACTION_USER_PRESENT BroadcastReceiver Not Be Registered In The Manifest?

Aug 30, 2010

I see that multiple broadcasts (ACTION_TIME_TICK, for example) cannot be registered in the manifest, the must be explicitly registered via Context.registerReceiver(). I am having trouble with the ACTION_USER_PRESENT broadcast intent. Specifically, I test on the emulator and my application keeps force closing with the error:

CODE:...................

This is caused by

CODE:.......................

My manifest is fairly simple:

CODE:........

I am essentially attempting to create a Receiver that is awakened as soon as possible after my application is installed. The first time it is awakened, it registers a few listeners, and then it unregisters itself so it is never called again. (I really wish there was an intent fired immediately after your app had been installed, to allow a small bit of setup.

View 1 Replies View Related

Android :: How To Take Screenshot In Programmatic Way?

Aug 4, 2009

How can I take a screenshot programmatically? So far I've learned that:

1) DDMS does it by sending "framebuffer:" to the adb service over a socket, which takes a screenshot in framebuffer_service.c that it sends back.
2) There are some proprietary screenshot apps out there that stipulate the user must have root access, I'm not sure why.

Would it be possible for an Android app to send "framebuffer:" to its own adb service and get the screenshot that way?

View 7 Replies View Related

Android :: Declarative (XML) Vs Programmatic UI

Apr 1, 2010

Has anyone seen or compiled benchmarks comparing declarative (XML) versus programmatically created UI's in Android? There are things that Google has done to speed up the declarative approach, but you still do have the layout inflation step done at runtime. Have you ever switched (or considered) changing your UI from declarative to programmatic for any reason?

View 1 Replies View Related

Android :: How To Set HTTP Proxy In Programmatic Way?

Sep 2, 2010

I'm looking for a programmatic way to set-up http proxy settings for android handsets. I've tried using android.provider.Settings.System.putString() to set System.HTTP_PROXY, but my call fails (I'm using a 2.2 emulator image at the moment). My code looks like:
if (System.putString(getContentResolver(), System.HTTP_PROXY, "10.10.2.1:8080")) {
tv.append("put for HTTP_PROXY succeeded. ");
} else { tv.append("put for HTTP_PROXY failed. "); }

I've also added to my android manifest:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
Although it's not clear from the docs which permission, if any, is required.

I'm familiar with this SO thread, but the technique there requires manual adb commands, which require the SDK tools and (possibly) a rooted phone. Is there a way to accomplish this? Ideally, I'd like away to set an http proxy that will be used for both data and WiFi connections.

View 1 Replies View Related

Android :: Programmatic UI - Setting IDs Of Some Elements

Feb 3, 2010

I need to add some parts of my UI programmatically. I'm doing this because I need to set the ids of some elements up in such a way that they can be easily access in a for loop. So far I have this xml:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/attr_row" android:layout_width="fill_parent"
android:layout_height="wrap_content"> <EditText android:id="@+id/attr_name"
android:hint="Attribute" android:layout_width="0dip" android:layout_weight="2"
android:layout_height="wrap_content" android:inputType="textPersonName" />
<EditText android:id="@+id/attr_val" android:hint="Value"
android:layout_width="0dip" android:layout_weight="3"
android:layout_height="wrap_content" android:inputType="textPersonName" />
<ImageButton android:id="@+id/drop_attr" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/btn_delete_states"
android:layout_gravity="center_vertical" /> </LinearLayout>

At the moment, I inflate this xml five times like so:
for (int i = 0; i<5; i++) { LinearLayout attrList = (LinearLayout) findViewById (R.id.attr_list);
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.attr_row, null);
LinearLayout extraAttr = (LinearLayout) row.findViewById (R.id.attr_row);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
attrList.addView(extraAttr, i, params); }

The link below shows two pictures - the layout hierarchy and the result in the emulator. http://picasaweb.google.com/bengoldcross/Android?authkey=Gv1sRgCJ785I...
As can be seen, the xml is inflated five times successfully but only one is actually displayed. Inspecting the hierarchy viewer a bit more explains why. The layout being displayed is at location x=0 y=111 all the others are being rendered at x=320 y=111. It would appear they are being displayed a) off screen and b) on top of each other. So, why are they and how do I stop it from happening?

View 3 Replies View Related

Android :: Programmatic Frame Layout Used As Button

Aug 26, 2010

Been stuck on this for a while and tried a few various things.Basically I've overridden frame layout to create myself a custom button. The frame layout has two children a button and a linearlayout with items in it.The problem is I'm trying to the get the button to stretch to the size of the frame layout (i.e. fill parent) and it isn't doing.

View 1 Replies View Related

Android :: How To Mount SD Card In Programmatic Manner?

Sep 15, 2010

I want to mount SD card programmatic, how can I check?

View 1 Replies View Related

Android :: Programmatic SD Card Mounting / Unmounting

Mar 1, 2010

I'm wondering how programmatic sd card mounting/unmounting can be achieved while the handset is connected to a pc via USB. I cannot find any managed API for that and also my jni attempts failed with errno: 1, [Operation not permitted] error.

View 1 Replies View Related

Android :: Email Programmatic Setup And Modification

May 12, 2010

I wanted to know if it is even possible to either set up or modify email account settings programmatically. I do not believe it is, due to email applications controlling their own settings (and thus would depend upon a ContentProvider from that specific client), but I have not yet found a definitive "no", either.

Further, I was wondering about the email account support on Android in general. It appears that Android 2.0 and above will allow for multiple ActiveSync/Exchange accounts and mulitple IMAP/POP3 accounts, and displays these in the same inbox. Is this claim true? Also, how is this different from the other major Android releases (Android 1.5 and 1.6)?

View 1 Replies View Related

Android :: Programmatic Way To Read System Logs?

Feb 3, 2010

Is there a programmatic way to read the system logs? i know they are stored in /dev/log.

View 4 Replies View Related

Android :: Programmatic Screen Capture On Mobile Device

Aug 27, 2010

I would like to implement some sort of remote assistance tool (like vnc) for Android. Is there the possibility to capture a screen programmatically on the device?

View 3 Replies View Related

Android :: Relative Layout XML Attributes Have No Obvious Programmatic Equivalent

Jun 16, 2009

If a RelativeLayout must be generated at run time, what are the equivalent API calls for the attributes set in the XML Layout editor? Take for example this very simple RelativeLayout that places the second ImageView to the right of the first ImageView:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/ android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal" android:background="@drawable/ bg_sunrise"
android:layout_gravity="center" android:gravity="center">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon"></ ImageView>
<ImageView android:id="@+id/ImageView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/ ImageView01" android:src="@drawable/icon"></ImageView> </RelativeLayout>

Of the many, variations I tried, I had the most hope for this one, but it didn't work either:

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
RelativeLayout layout = new RelativeLayout(this);
layout.setLayoutParams( new ViewGroup.LayoutParams (
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ) );
ImageView imageView1 = new ImageView(this);
imageView1.setImageResource(R.drawable.icon);
imageView1.setAdjustViewBounds(true);
// set the ImageView bounds to match the Drawable's dimensions
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_TOP); layout.addView(imageView1, params1);
ImageView imageView2 = new ImageView(this); imageView2.setImageResource(R.drawable.icon);
imageView2.setAdjustViewBounds(true); // set the ImageView bounds to match the Drawable's dimensions
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams
(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params2.addRule(RelativeLayout.RIGHT_OF, imageView1.getId());
layout.addView(imageView2, params2); this.setContentView(layout); }

Can anyone offer the Java equivalent to the above XML? Can anyone explain why there is no attribute, getter/setter, or method for accessing the properties that can be set in XML? What is the most elegant solution for dynamically creating Layouts, Views, and other Resources on the Android platform when there is no Java programmatic equivalent?

View 11 Replies View Related

Android :: Registering As Developer HELP

Apr 23, 2010

I'm a student developer. I have developed few apps for Android, I wanted to publish them in the Android Market, but I don't have access to Credit Card for sign up process as Banks won't issue credit cards for students (people with no income). Is there any alternative for this?

View 4 Replies View Related

Android :: Registering For C2DM Framework

Sep 5, 2010

I'm trying to test the C2DM framework. I got the confirmation email a couple of days ago and then tryied to create a client that could register. For that purpose, I created a simple client following the steps described in this tutorial:
http://code.google.com/intl/es-419/android/c2dm/index.html.

The Android manifest file contains among other things this code:
<permission android:name="com.bilthon.ufrj.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.bilthon.ufrj.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"/>
<receiver android:name=".C2DMReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter> <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.bilthon.ufrj" /> </intent-filter>
<intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.bilthon.ufrj" /> </intent-filter> </receiver>

And then, the main activity launched when the program starts has the following code:
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
// boilerplate registrationIntent.putExtra("sender","mytestemail@gmail.com");
Log.d("WelcomeScreen","mytestemail@gmail.com");
startService(registrationIntent);

I also registered a google account on the AVD running my client, as they said it was required. But the problem is that I cannot get the broadcast receiver to "wake up". I don't know what could be wrong. By analysing the logs, I can see that the registration intent is created and apparently used correctly, but the receiver code just never is executed, what could be wrong?

View 3 Replies View Related

Android :: Registering Textview And Webview Clicks

Aug 2, 2010

i may get flamed for this question, but help me do it right. I was downloading images from a website and putting them into a database, and then displaying them in an imageview. well to reduce the size of my database, i changed from an imageview to a webview and now only do a Webview.Loaddata(ImageLink). all of this is contained within a listactivity.my problem seems to be that for whatever reason now i dont seem to be capturing the Listclick event any longer

View 2 Replies View Related

Android :: HEADSET PLUG Not Registering As Receiver

Oct 6, 2009

I'm trying to create application fixing problem with audio volume in headset/handset(I cannot find such application in the market).There is ACTION_HEADSET_PLUG intent,but I cannot register it in manifest. Registering it using registerReceiver does not make sense becouse app should be run always when headset is plugged/unplugged, app will also have no GUI/Activity.

View 4 Replies View Related

Android :: Better Keyboard Not Registering Fast Typing

Apr 4, 2010

The better keyboard application is better than the stock keyboard in almost every way. But there is one big problem with it that I've found, and that's that it has trouble registering two nearby keys tapped in rapid succession, often registering neither of them. If I try and type "that" with two fingers, I'll often just get "th"-- it interprets left thumb pressing "a" and right thumb pressing "t" as... nothing, I guess.

View 16 Replies View Related

Android :: Registering Sync Service Programmatically

Dec 16, 2009

How can I register a sync-service programmatically? For example:

<service android:exported="true" android:name="com.example.test.SyncService">
<intent-filter> <action android:name="android.content.SyncAdapter" />
</intent-filter> <meta-data android:name="android.content.SyncAdapter" android:resource="@xml/syncadapter" /> </service>

How would I register this service at run-time?

View 4 Replies View Related

Android :: How Can I A Context Menu Without Registering View

Aug 4, 2010

How can I open a context menu for a view without registering it using registerForContextMenu()?

My activity overrides onTouchEvent to detect motion, and if I use registerForContextMenu() it stops working. I'm detecting a long press, so I'd like to forward that request to a method that would build the menu for me, but don't know if it can work that way.

View 2 Replies View Related

Android :: Syntax Error In C2DM Registering In Google Example

Jul 30, 2010

its not that big deal but i found a Syntax error in the code for C2DM Registering from this site registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0); where they missing the end ")" and here's my magical fix :) registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));

View 2 Replies View Related

Android :: Local Service Not Registering - Force Closes

May 6, 2010

Essentially my problem is this, I open my Activity. It binds to a local service that "appears" to be connected. I get a force close when I press the back button:

"IllegalArgumentException: Service not registered" when unbind is called in my onPause method...
public void onPause() { super.onPause(); if (isFinishing()) {
if (mConnection != null){ Log.i(TAG,"onPause, mConnection" + mConnection.toString());
mDbS.unbindService(mConnection); }else { Log.i(TAG,"mConnection is null");
} The service is bound in onCreate // bind to our sdCard database using our Service Connection
mServiceIntent = new Intent(this,DatabaseService.class);
if(bindService(mServiceIntent, mConnection, Context.BIND_AUTO_CREATE)){
Log.e(TAG, "service bound"); }else{ Log.e(TAG, "service not bound");
} bindService is returning true.

My Service connection is as follows. onServiceConnected is called and goes to completion. onService Disconnected is never called (presumably because my service is in same process)
private ServiceConnection mConnection = new ServiceConnection() {
public final String TAG = "LoadView.ServiceConnection"; //$NON- NLS-1$
public void onServiceConnected(ComponentName className, IBinder service) {
mDbS = ((LocalBinder<DatabaseService>) service).getService(); .....
stuff not relevant.... Log.i(TAG, "finished onServiceConnected");
//$NON-NLS-1$ } public void onServiceDisconnected(ComponentName className) {
Log.e(TAG, "onServiceDisconnectedCalled"); //$NON-NLS-1$ } };

The only thing I do a little different is that I don't use an inner class in my service for the Binder object - I use a separate class. This is mostly because I have several databases and wanted code I could reuse and set up simply rather than worry about all the ins and outs and memory leak issues.

import android.os.Binder; import android.util.Log;
public class LocalBinder<S> extends Binder { private String TAG = "LocalBinder";
private S mService; @SuppressWarnings("unused") private LocalBinder() {
} public LocalBinder(S service){ mService = service;
} public S getService() { return mService;
} public void finalize(){ mService = null;
try { //TODO reinstate this after Issue 8046 is resolved
//super.finalize(); } catch (Throwable e) { Log.e(TAG,"Unable to finalize Binder");
} } }

View 2 Replies View Related

Android :: Registering Broadcast Receiver To Run When Application Launched?

Aug 13, 2010

I want to run some code when an app is launched, so my broadcast receiver has to be notified when user open any app.

View 1 Replies View Related

Android :: Prolonged Touching In One Area Causes OnTouchEvent To Stop Registering?

Jan 12, 2010

I'm trying to do something in my app where you have to hold your finger on the screen for more than 30 seconds. After about 30 seconds, it stops sending onTouchEvents for that part of the screen, almost like a "dead zone." Tested on a motorola droid, and is there any way to stop this from happening?

View 6 Replies View Related

Android :: Registering For Proximity Alert Doesn't Work For More Than One Location

Oct 19, 2010

I am trying to register to several proximity alerts. Here's an excerpt:................

View 3 Replies View Related

Android :: Registering Context Menu For Custom List Adapter

May 11, 2010

made a custom list adapter extending the Base adapter. Each item in the list has an imagebutton, 2 textviews and a button. I tried to add the context menu to the list so as to display some options for an item in the list. registerForContextMenu(getListView()); I used a MenuInflater object to inflate the context menu xml file. But on clicking the items in the list nothing shows up or the usual highlighting of the item of list on click isn't shown. Is it that the context menu doesn't work for custom list views? Any help would be much appreciated.

View 1 Replies View Related

Android :: Registering OnClick Listener On Application Widget Button

May 15, 2010

I'm creating my first widget and ran into a snag. I have several buttons on this widget and need a way to register an onClick action for each of the buttons. So far I've only found examples where they start a configuration activity from a widget button. Does someone have example code on using buttons in home screen widgets?

View 4 Replies View Related

Android :: SMS Using BroadcastReceiver

Mar 5, 2010

I am writing my own sms receiver app and i want it to catch all the sms using a broadcast receiver. This on its own, is no problem, but i want to be able to stop the message being passed to the messaging app.

View 2 Replies View Related

Samsung Galaxy S :: Flashing Back To Android 2.1 - Odin Not Registering Phone

Nov 8, 2010

I want to flash my phone back to android 2.1. My phone is in download mode but odin is not picking it up?

View 3 Replies View Related

Android :: How To Make Use Of Views Defined In Layout XML File As Template To Create Views Programmatic Way

Feb 28, 2010

I want to populate a table, defined in layout xml file through the programmatic way. I have define Table with a single row defining its header, with all the attributes set. Now i want to know a way so that i can just replicate that header row in the table with new content.

I tried using inflator inflate(int,view) method, but at runtime it showed up with error.

Here is the XML code for the layout file defining the table

CODE:.................

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved