Search Results

Search found 130 results on 6 pages for 'intents'.

Page 2/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Unexpected behavior of IntentService

    - by kknight
    I used IntentService in my code instead of Service because IntentService creates a thread for me in onHandleIntent(Intent intent), so I don't have to create a Thead myself in the code of my service. I expected that two intents to the same IntentSerivce will execute in parallel because a thread is generated in IntentService for each invent. But my code turned out that the two intents executed in sequential way. This is my IntentService code: public class UpdateService extends IntentService { public static final String TAG = "HelloTestIntentService"; public UpdateService() { super("News UpdateService"); } protected void onHandleIntent(Intent intent) { String userAction = intent .getStringExtra("userAction"); Log.v(TAG, "" + new Date() + ", In onHandleIntent for userAction = " + userAction + ", thread id = " + Thread.currentThread().getId()); if ("1".equals(userAction)) { try { Thread.sleep(20 * 1000); } catch (InterruptedException e) { Log.e(TAG, "error", e); } Log.v(TAG, "" + new Date() + ", This thread is waked up."); } } } And the code call the service is below: public class HelloTest extends Activity { //@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent selectIntent = new Intent(this, UpdateService.class); selectIntent.putExtra("userAction", "1"); this.startService(selectIntent); selectIntent = new Intent(this, UpdateService.class); selectIntent.putExtra("userAction", "2"); this.startService(selectIntent); } } I saw this log message in the log: V/HelloTestIntentService( 848): Wed May 05 14:59:37 PDT 2010, In onHandleIntent for userAction = 1, thread id = 8 D/dalvikvm( 609): GC freed 941 objects / 55672 bytes in 99ms V/HelloTestIntentService( 848): Wed May 05 15:00:00 PDT 2010, This thread is waked up. V/HelloTestIntentService( 848): Wed May 05 15:00:00 PDT 2010, In onHandleIntent for userAction = 2, thread id = 8 I/ActivityManager( 568): Stopping service: com.example.android/.UpdateService The log shows that the second intent waited the first intent to finish and they are in the same thread. It there anything I misunderstood of IntentService. To make two service intents execute in parallel, do I have to replace IntentService with service and start a thread myself in the service code? Thanks.

    Read the article

  • startActivityForResult to an activity that only displays a progressdialog

    - by Alxandr
    I'm trying to make an activity that is asked for some result. This result is normally returned instantly (in the onCreate), however, sometimes it is nesesary to wait for some internet-content to download which causes the "loader"-activity to show. What I want is that the loader-activity don't display anything more than a progressdialog (and that you can still se the old activity calling the loader-activity in the background) and I'm wondering wheather or not this is possible. The code I'm using as of now is: //ListComicsActivity.java public class ListComicsActivity extends Activity { private static final int REQUEST_COMICS = 1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_comics); Button button = (Button)findViewById(R.id.Button01); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intents.ACTION_GET_COMICS); startActivityForResult(intent, REQUEST_COMICS); } }); } /** Called when an activity called by using startActivityForResult finishes. */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Toast toast = Toast.makeText(this, "The activity finnished", Toast.LENGTH_SHORT); toast.show(); } } //LoaderActivity.java (answers to Intents.ACTION_GET_COMICS action-filter) public class LoaderActivity extends Activity { private Intent result = null; private ProgressDialog pg = null; private Runnable returner = new Runnable() { public void run() { if(pg != null) pg.dismiss(); LoaderActivity.this.setResult(Activity.RESULT_OK, result); LoaderActivity.this.finish(); } }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String action = getIntent().getAction(); if(action.equals(Intents.ACTION_GET_COMICS)) { Runnable loader = new Runnable() { public void run() { WebProvider.DownloadComicList(); Intent intent = new Intent(); intent.setDataAndType(ComicContentProvider.COMIC_URI, "vnd.android.cursor.dir/vnd.mymir.comic"); returnResult(intent); } }; pg = ProgressDialog.show(this, "Downloading", "Please wait, retrieving data...."); Thread thread = new Thread(null, loader, "LoadComicList"); thread.start(); } else { setResult(Activity.RESULT_CANCELED); finish(); } } private void returnResult(Intent intent) { result = intent; runOnUiThread(returner); } }

    Read the article

  • Convert JSON String to Java Object or HashMap

    - by Priyank
    Hi. I am writing an android app. I want to pass some data across the intents/activities and I feel that a conversion to and from JSON is probably a more optimal way at this point. I am able to convert a java hashmap to a json string successfully using JSONObject support. However i need to convert back this JSON string to a java object or a hashmap. What is the best way to go about it. Is parcelable really a change worth doing; if I have simple 5 field object? What are the other ways to transfer data between intents. Cheers

    Read the article

  • Can't get a LiveFolder to launch my activity like it should

    - by Felix
    I was able to create a ContentProvider for a LiveFolder, but I can't seem to be able to create my intents correctly, so it always gives "Application is not installed on your phone" errors when clicking on items inside the folder. My Activity is defined like so, in the manifest: <activity android:name=".MyActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> Then, I create the intents I place in the LiveFolders.INTENT column like this: i = new Intent(); i.setAction(null); i.setClassName("my.package.here", ".MyActivity"); I don't get why this is not working. Maybe I'm making some stupid mistake, but please point me in the right direction.

    Read the article

  • How to use intent between tabs in java/Android?

    - by Praveen Chandrasekaran
    I would need to know how to handle the intent between tabs. For example, I have a tab activity with two tabs. First on content is a text view. another one is a map view. When i click that text view it redirects to the tab2. it can be easily achieved by setCurrentTab(1) or setCurrentTabByTag("tab2") methods. But i want to pass lat and long values to that Map Activity to drop pin. What is the better way to use intents or getter/setter in java? What do you prefer? if your answer is "Intents". How?

    Read the article

  • Chrome Apps Office Hours: TextDrive and AngularJS

    Chrome Apps Office Hours: TextDrive and AngularJS Ask and vote for questions: goo.gl In this episode, the AngularJS team joins us to talk about how they used Angular to build TextDrive. TextDrive is an open source text editor application that demonstrates of the power and simplicity of AngularJS and Chrome Apps. It features integration with Google Drive, web intents, and Ace (ace.ajax.org) in a simple and clean interface built upon HTML5 and web standards. To learn more visit github.com From: GoogleDevelopers Views: 0 0 ratings Time: 00:00 More in Science & Technology

    Read the article

  • preparing SMS app for Android KitKat

    - by Pmsc
    in agreement with the recent post from Android Developers http://android-developers.blogspot.pt/2013/10/getting-your-sms-apps-ready-for-kitkat.html ,I was trying to prepare my app to the new android version, but encountered a problem with the part they suggest to create a dialog to let the user set the app as the default application to handle SMS's : Android Developers Post public class ComposeSmsActivity extends Activity { @Override protected void onResume() { super.onResume(); final String myPackageName = getPackageName(); if (!Telephony.Sms.getDefaultSmsPackage(this).equals(myPackageName)) { // App is not default. // Show the "not currently set as the default SMS app" interface View viewGroup = findViewById(R.id.not_default_app); viewGroup.setVisibility(View.VISIBLE); // Set up a button that allows the user to change the default SMS app Button button = (Button) findViewById(R.id.change_default_app); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, myPackageName); startActivity(intent); } }); } else { // App is the default. // Hide the "not currently set as the default SMS app" interface View viewGroup = findViewById(R.id.not_default_app); viewGroup.setVisibility(View.GONE); } } } the code itself in pretty much straightforward, but I'm unable to access to Telephony.Sms.getDefaultSmsPackage because it says that Telephony cannot be resolved, and I can't find any import or declaration that would fix that. Can anyone please help? Thanks in advanced.

    Read the article

  • Stream audio source from Mac OS X as MP3

    - by Adam Backstrom
    I'd like to broadcast audio from my Mac desktop to my Palm Pre, as the Pre is more portable and I can use it in the kitchen, or while I'm exercising, and so on. I can already capture the audio using Soundflower, but how might I create an MP3 stream out of the audio input device? For all intents and purposes, Soundflower can reduce this question down to, "How can I create an MP3 stream from the built-in microphone on my Mac?" as the answer can be applied equally well to iTunes output.

    Read the article

  • Flash: Memory usage is low but framerate keeps dropping

    - by Cyborg771
    So I'm working on a puzzle game in flash. For all intents and purposes it's like Tetris. I spawn blocks, they move around the screen, then they get destroyed and disappear. I was having some trouble with the memory usage being too high over time so I read up on memory management and I think I have that figured out now. It's definitely climbing slower than it was before, but the framerate is still taking a huge dive after playing for a while. If it's not a memory leak what else could be causing this? Thanks in advance.

    Read the article

  • Server asks for username and password on boot

    - by Jon
    I installed the Ubuntu server 12.04 easily, however, when I boot it asks for a username and password. I don't know my previous username or password from Windows XP. I am currently trying to install any version of Ubuntu I have in my arsenal to recover the PC, but all intents so far have failed. They worked on other computers but not on this one, the error I get is No DEFAULT or UI configuration directive found! I have tried all the solutions found on this site but to no avail. I don't have a Windows Ultimate boot disk and I'm out of CDs to burn. I can, however, make live USBs. Any Suggestions?

    Read the article

  • How to use Broadcast Receiver in different Applications in Android?

    - by Sebi
    Hi I have here two applications in two different projects in eclipse. One application (A) defines an activity (A1) which is started first. Then i start from this activity the second activity (B1) in the second project (B). This works fine. I start it the following way: Intent intent = new Intent("pacman.intent.action.Launch"); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); Now i want to send intents bewtween the two activities by using broadcast receivers. In activity A1 i send the intents the following way: Intent intent = new Intent("pacman.intent.action.BROADCAST"); intent.putExtra("message","Wake up."); sendBroadcast(intent); The part of the manifest file in activity A1 that is responsible for this broadcast is the following: <activity android:name="ch.ifi.csg.games4blue.games.pacman.controller.PacmanGame" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.BROADCAST" /> </intent-filter> </activity> In the receiving activity, I define the receiver the following way in the manifest file: <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".PacmanGame" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="pacman.intent.action.Launch" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <receiver android:name="ch.ifi.csg.games4blue.games.pacman.controller.MsgListener" /> </activity> </application> The class message listener is implemented this way: public class MsgListener extends BroadcastReceiver { /* (non-Javadoc) * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent) */ @Override public void onReceive(Context context, Intent intent) { System.out.println("Message at Pacman received!"); } } Unfortunately, the message is never received. Although the method in activity A1 is called, i never receive an intent in B1. Any hints how to solve this? Thanks a lot!

    Read the article

  • Android: how to share code between projects signed with the same certificate

    - by tomash
    In Android documentation concerning code signing we can read: "By signing multiple applications with the same certificate and using signature-based permissions checks, your applications can share code and data in a secure manner." How exactly such code sharing can be done? Is it possible to release main application and multiple exchangeable plugins then discover them at runtime? What does source code looks like and what are advantages over "standard" intents calls from/to different APK packages?

    Read the article

  • Launch app with URL

    - by Carlos Portes
    Hello everyone! I've read about intents in android but here goes my question. I'd like to launch an app on my android phone with the click of a link in the web browser. Example: If the link is "mycam://http://camcorder.com", "mycam://" acts as some kind of "tag" to launch my app but I'd like to pass "http://camcorder.com" as a string to that app on start. Help please! Thanks!

    Read the article

  • Reminder application

    - by Abhishek Mishra
    I am developing a reminder application. I am generating notifications using notification manager class, when the timeline crosses.But if my cell phone is switched off ,I am unable to see these notifications. Not even when i switch it on again. Even if i switch it off and switch on again, i think the pending intents are destroyed and no notification is generated. How do i get it when the phone is switched on again ?

    Read the article

  • Downloading mp3 files in java on Android

    - by drozzy
    What is the best way to download an mp3 file in java (on Android sdk)? http://developer.android.com/reference/java/net/package-summary.html Should I be using sockets? If so - what kind of "Stream" reader should I use? I have also read something about "intents" - is this something that is applicable here? I am also curious as to what should one do if connection gets interrupted - can I resume the download somehow or restart it? Any tips?

    Read the article

  • Ruby (and Rails) nested module syntax

    - by brad
    I'm wondering what the difference is between the following two modules # First Example module Parent module Child end end and # Second Example module Parent::Child end Using the 2nd method, it appears as though the Parent module must be previously defined, otherwise I get an 'uninitialized constant' error Given this, what is the preferred way of defining modules such as this and then adding nested children with regards to syntax and file structure (ie. folders etc). Reference to a Rails way would be greatly appreciated. Are these two examples for all intents and purposes equivalent?

    Read the article

  • Force Tab Activity creation?

    - by Daniel
    I have a TabHost and several tabs added to it. Problem: The activities on these tabs are not created until the tab is pressed. My tabhost is broadcasting intents but my broadcast receivers are not registered until onCreate in my tab activities is called. Is there any way to force activity creation? Maybe my tabhost can call setCurrentTab and switch back to main tab(0), but is that really the best option available?

    Read the article

  • Distinguish between screen timeout and power-button-press?

    - by Nick
    Hi, my app does something when the screen goes black, but I want it to only carry out that task if the screen was turned off "by itself", through a screen timeout - NOT when the user presses the power-button. Is there any way to distinguish between those two events? ACTION_SCREEN_OFF obviously fires in both cases, and I haven't found any other intents that might match what I'm looking for. Thanks for your help, Nick

    Read the article

  • android: how do i open another app from my app?

    - by mtmurdock
    I understand how to use intents and startActivity() when opening another activity within my own app, but how do you start a different app? specifically: -how do you determine if the user has the needed app installed on their device? -how do you start that app? -how do you pass parameters to that app? -how do you find all this info out for a specific app (say Adobe reader, or google maps)?

    Read the article

  • Android TabLayout custom menu

    - by MostafaEweda
    I have a TabLayout containing tabs as intents to activities. I want to set custom menu items for each tab, but the onCreateOptionsMenu version called is the Host's version. How can I make the menu items created by each activity on its own.

    Read the article

  • MySQL-5.5.10 - Lost connection to MySQL server during query (Both Web Clients and MySQL Slaves)

    - by kwiksand
    We've just upgraded our existing MySQL5.1 DB servers to newer (much better) hardware with MySQL 5.5, and things have been going mostly smoothly for almost 6 weeks. Just the last few days, I've noticed a few errors, such as: From a MySQL Slave: [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013) Or From Apache/Other: Lost connection to MySQL server at 'reading initial communication packet', system error: 110 At one point this evening, many webnodes reported this error for a three minute period (many such reports as this was in a busy period). However, the issues don't appear to correspond with any times of extreme load. For all intents and purposes, the connection/thread load on MySQL is at a normal rate (between about 10 and 40 connected threads), and Web load has been a LOT higher at times over the last few weeks. Could there bee other reasons for these connection errors, that I'm not seeing?

    Read the article

  • Modeling RBAC actors using LDAP (Core X.5xx)

    - by Tetsujin no Oni
    Mirrored from stackoverflow... When implementing an RBAC model using an LDAP store (I'm using Apache Directory 1.0.2 as a testbed), some of the actors are obviously mappable to specific objectClasses: Resources - I don't see a clear mapping for this one. applictionEntity seems only tangentially intended for this purpose Permissions - a Permission can be viewed as a single-purpose Role; obviously I'm not thinking of an LDAP permission, as they govern access to LDAP objects and attributes rather than an RBAC permission to a Resource Roles - maps fairly directly to groupOfNames or groupOfUniqueNames, right? Users - person In the past I've seen models where a Resource isn't dealt with in the directory in any fashion, and Permissions and Roles were mapped to Active Directory Groups. Is there a better way to represent these actors? How about a document discussing good mappings and intents of the schema?

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >