Search Results

Search found 3983 results on 160 pages for 'activity'.

Page 3/160 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Detailed android activity lifecycle (onAttachedToWindow())

    - by Ralkie
    I'm interested in android activity lifecycle and I would like to get more detailed description/documentation/reference than widely available basic (onCreate-onStart-onResume) one. My need comes from realizing that starting new activity (Theme.Dialog styled) from onAttachedToWindow() greatly improves response time if comparing to starting it from onCreate(). I wonder how this onAttachedToWindow() fits into whole android activity lifecycle. Official API ref description "Called when the window has been attached to the window manager" doesn't help a lot.

    Read the article

  • How to pass object from one activity to another in android

    - by kaibuki
    Hi I am trying to work on sending an object of my "Customer" class from one activity and display on other activity. the code for the customer class : `package com.kaibuki; public class Customer { private String firstName, lastName, Address; int Age; public Customer(String fname, String lname, int age, String address) { firstName = fname; lastName = lname; Age = age; Address = address; } public String printValues() { String data = null; data = "First Name :" + firstName + " Last Name :" + lastName + " Age : " + Age + " Address : " + Address; return data; } } I want to send its object from one activity to another and then display the data on the other activity. Please need urgent help. Thanks alot Kai`

    Read the article

  • Conditional restart on Activity onConfigurationChanged

    - by yuku
    I want to make an activity that allows orientation changes on some condition, but not otherwise. More exactly I want to prevent restarting the activity when a background thread is busy. I have put the configChanges attribute on the activity manifest, and onConfigurationChanged is called when the orientation changes. However I want to allow the app to change the orientation when allowed. @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (orientationChangeAllowed) { // how to I restart this activity? } else { // don't do anything } }

    Read the article

  • android surfaceview is no longer visible after back from other activity

    - by user308748
    i have a question in developing some android program... i use surfaceview for camera preview. it works fine, but has one problem when i start other activity (by clicking something) and then back from that activity. after that, surfaceview is no longer visible. (but onclicklistener is working) but when i occur surfacecreated/destoryed by visible/invisible surfaceview in single activity, it works very good. plz give me any help.

    Read the article

  • Positioning elements outside an Activity on Android

    - by Aleksander Kmetec
    Is there a way to absolutely position an UI element on Android so that it is located outside an Activity? For example: can you create a fullscreen ImageView simply by moving/resizing an ImageView inside an existing regular Activity instead of creating a new fullscreen activity? EDIT: Re-reading my question I see I wasn't very clear about what I'm trying to accomplish. I'd like to temporarily extend an element to cover the notification bar at the top of the screen. I need to create a semitranslucent fullscreen overlay but since translucent activities cannot cover the notification bar I'm trying to find out if it's possible for an element to break out of activity's bounds and resize itself to fill the whole screen, top to bottom.

    Read the article

  • Using intent.getStringExtra from within an activity

    - by Lakshmie
    I am relatively new to android. I have two applications A and B. I have an activity in A, lets name it x, that would launch the application B. Now the intent sent by x contains StringExtra that I want the Starting activity in B to use. Is there a way for the activity in B to do that? Thanks!

    Read the article

  • Click on notification starts activity twice

    - by Karussell
    I'm creating a notification from a service with the following code: NotificationManager notificationManager = (NotificationManager) ctx .getSystemService(Context.NOTIFICATION_SERVICE); CharSequence tickerText = "bla ..."; long when = System.currentTimeMillis(); Notification notification = new Notification(R.drawable.icon, tickerText, when); Intent notificationIntent = new Intent(ctx, SearchActivity.class). putExtra(SearchActivity.INTENT_SOURCE, MyNotificationService.class.getSimpleName()); PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0); notification.setLatestEventInfo(ctx, ctx.getString(R.string.app_name), tickerText, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(1, notification); The logs clearly says that the the method startActivity is called twice times: 04-02 23:48:06.923: INFO/ActivityManager(2466): Starting activity: Intent { act=android.intent.action.SEARCH cmp=com.xy/.SearchActivity bnds=[0,520][480,616] (has extras) } 04-02 23:48:06.923: WARN/ActivityManager(2466): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.SEARCH cmp=com.xy/.SearchActivity bnds=[0,520][480,616] (has extras) } 04-02 23:48:06.958: INFO/ActivityManager(2466): Starting activity: Intent { act=android.intent.action.SEARCH cmp=com.xy/.SearchActivity bnds=[0,0][480,96] (has extras) } 04-02 23:48:06.958: WARN/ActivityManager(2466): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.SEARCH cmp=com.xy/.SearchActivity bnds=[0,0][480,96] (has extras) } 04-02 23:48:07.087: INFO/notification(5028): onStartCmd: received start id 2: Intent { cmp=com.xy/.NotificationService } 04-02 23:48:07.310: INFO/notification(5028): onStartCmd: received start id 3: Intent { cmp=com.xy/.NotificationService } 04-02 23:48:07.392: INFO/ActivityManager(2466): Displayed activity com.xy/.SearchActivity: 462 ms (total 462 ms) 04-02 23:48:07.392: INFO/ActivityManager(2466): Displayed activity com.xy/.SearchActivity: 318 ms (total 318 ms) Why are they started twice? There are two identical questions on stackoverflow: here and here. But they do not explain what the initial issue could be and they do not work for me. E.g. changing to launchMode singleTop is not appropriated for me and it should work without changing launchMode according to the official docs (see Invoking the search dialog). Nevertheless I also tried to add the following flags to notificationIntent Intent.FLAG_ACTIVITY_CLEAR_TOP | PendingIntent.FLAG_UPDATE_CURRENT but the problem remains the same.

    Read the article

  • Allowing AsyncTask to Manipulate Values in Different Activity Classes

    - by Matt
    Hi guys, This title may seem strange, so let me try to explain what I'm trying to do. I have several activity classes, each representing a different view in my application. My initial activity class gets loaded when the application launches. The user enters values and eventually a TCP socket is opened, and I then use AsyncTask to listen for and respond to messages from the server. I'd like for this AsyncTask class to essentially listen until the app is closed/error condition reached, and be able to update values in other activity classes after they are started. Does this make sense (it's been a long, frustrating night)? I know that static activity class references are bad practice, and touching the UI thread from other activities is bad as well, but I'm having trouble finding a clean solution to this problem. Maybe using AsyncTask is not the best approach here? Should I be using a service instead or something else entirely? Thanks in advance.

    Read the article

  • Listing an application's activity and intent-filters?

    - by MBonig
    I am interested in activating another application's activity. I know from reading the Android SDK that it's probably better to do this with an implicit intent. However, this activity doesn't reside in an application I own, so I don't know the action and category and data flags on the intent-filter. How can I examine an Android applications metadata like the activity classes and the intent-filters for those activities (if declared in the manifest)? Thanks!

    Read the article

  • Problems with starting an activity in onStart

    - by Fizz
    Hello everyone. I'm trying to start a floating activity from onStart to retrieve some info from the user right when the initial activity begins. I have the following: @Override public void onStart(){ super.onStart(); callProfileDialog(); } And callProfileDialog() is just: private void callProfileDialog(){ Intent i = new Intent(this, com.utility.ProfileDialog.class); startActivityForResult(i, PROFDIALOG); } ProfileDialog.class returns a String from an input box. If the result returned is RESULT_CANCELED then I restart the activity. The problem I'm having is that when the program starts, the screen is just black. If I hit the Back button a RESULT_CANCELED is returned then the initial activity shows as well as the floating activity (since it recalled itself when it got a RESULT_CANCELED). Why can't I get the activities show by calling ProfileDialog.class from onStart()? I got the same result when I called it at the end of onCreate() which is way I switch over to use onStart(). Thanks for the help.

    Read the article

  • [Android] Pass variable/intent to an activity when launched from a Widget

    - by Pelly
    Hi, Currently within an activity in my application I can call another activity and pass a variable to it in the following manner: Intent myIntent = new Intent(parentView.getContext(), ShowStations.class); myIntent.putExtra("stationName", stations[position].StationName); startActivity(myIntent); This works fine, but now I want to be able to do the same from my Widget. Currently this code works fine for launching a specific activity from my widget: Intent WidgetIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("grell.com", "grell.com.FavStations")); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, WidgetIntent, 0); updateViews.setOnClickPendingIntent(R.id.widget_main, pendingIntent); So now I am wondering how can I launch the same activity as shown in the first example but also pass through the 'stationName' variable. Any help would be greatly appreciated. Cheers

    Read the article

  • How Many States Does an Activity Have?

    - by Android Eve
    The Activity lifecycle section in the Application Fundamentals tutorial states that there are 3 states: An activity has essentially three states: (1. active/running 2. paused 3. stopped) But then as I continued reading the actual Activity class documentation, the Activity Lifecycle section states that there are 4 state: An activity has essentially four states: (1. active/running 2. paused 3. stopped 4. "dropped"?) Both sources (on the same website) agree about the first 3, but the 4th one is only mentioned in the class documentation and is unnamed. So, are there really 4 states or only 3? If there are 4, what is the name of the 4th one? Please help me understand this discrepancy. Also, highlighted colored blocks in this beautiful and very informative flowchart don't seem to correspond to the states. Where, in the flowchart, would you mark the 3 or 4 states?

    Read the article

  • Prevent Activity from saving state when user selects back button

    - by martinjd
    I have an Activity with a list that is bound to a ListAdapter reading data into a ArrayList from a database. All is well when the data is first loaded. While the Activity is open and the list is being displayed it is possible and likely that the data in the database will be updated by a service but the list does not reflect the changes because the ArrayList does not know about the changes. If the Activity is no longer in the foreground as would be the case if the user goes to the home screen and then is brought back to the foreground I would like for the Activity to not display what it did prior but rather reload the data using the ListAdapter the view is bound to. I think something needs to call finish() but I am not sure what. This is what I have in the Activity. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setUpViews(); app = (MyApplication) getApplication(); adapter = new MyListAdapter(this, app.getMyEvents()); setListAdapter(adapter); } @Override protected void onResume() { super.onResume(); adapter.forceReload(); }

    Read the article

  • ListView Item Detail Screen: New or Same Activity?

    - by stormin986
    I have a listview where each item correlates to an instance of an item in an array. When the user selects an item, it will bring up a 'Details' page that reads and displays other data members of the list item. Would this be better implemented with the Details page as its own activity, or a new view within the same activity? Pros and cons of each? A new activity makes my job a little easier in terms of handling the 'back' button, but then I have the challenge of how do I pass the rest of the data structure to the new activity since I can't bundle it up (unless I serialize it).

    Read the article

  • launching mapview from main activity (button)

    - by arc
    Hi all. Going round in circles here i think. I have an activity called Locate; public class Locate extends Activity { public static String lat; public static String lon; public static String number; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.locate); final Button buttonMaps = (Button) findViewById(R.id.ButtonMaps); buttonMaps.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); try { Intent i = new Intent(getBaseContext(), displayMap.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } catch (ActivityNotFoundException e) { Toast.makeText(getBaseContext(), "Activity Not Found", Toast.LENGTH_SHORT).show(); } }}); // Toast.makeText(getBaseContext(), "lat: " + lat + " long: " + lon + " from: " + testname, Toast.LENGTH_LONG).show(); } If I make the displayMap class into a normal Activity, and just have display a toast message confirming it has loaded - then it works fine. If i do this though; public class displayMap extends MapActivity { /** Called when the activity is first created. */ public void onCreate() { setContentView(R.layout.displaymap); Toast.makeText(getBaseContext(), "Display Map", Toast.LENGTH_SHORT).show(); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } Then as soon as I click the Button, I get a force close. I have the correct 'uses-library' tag in my manifest; <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps" /> I don't get what it just force closes everytime i try and load it. If I make this my onClick handler then it will fire up a working googlemaps/default mapview public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); Uri uri=Uri.parse("geo:"+Locate.lat+","+Locate.lon); StartActivity(new Intent(Intent.ACTION_VIEW, uri)); } But that is not what I am trying to do, I want my own - so that I can add overlays etc to it. But it does prove that the permission are set correctly and that the lib is there. The logcat error when the app FCs is a Unexpected DEX error. Can anyone point in the right direction here?

    Read the article

  • Android Status Bar Notifications - Opening the correct activity when selecting a notification

    - by Mr Zorn
    I have been having a problem with a notification not opening/going to the correct activity when it has been clicked. My notification code (located in a class which extends Service): Context context = getApplicationContext(); CharSequence contentTitle = "Notification"; CharSequence contentText = "New Notification"; final Notification notifyDetails = new Notification(R.drawable.icon, "Consider yourself notified", System.currentTimeMillis()); Intent notifyIntent = new Intent(context, MainActivity.class); PendingIntent intent = PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_AUTO_CANCEL); notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent); ((NotificationManager)getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notifyDetails); If I click the notification while the application which created the service is open, the notification disappears (due to the FLAG_AUTO_CANCEL) but the activity does not switch. If I click the notification from the home screen, the notification disappears and my app is brought to the front, however it remains on the activity which was open before going to the home screen, instead of going to the main screen. What am I doing wrong? How do I specify the activity that will be pulled up?

    Read the article

  • Android Video Layout and backbutton to activity

    - by Marcjc
    I have an application where you can click on a button, this takes you to a new activity with four new buttons, listen, bio, ringtone, and watch. My watch button kicks off the following code: Button cmd_watchme = (Button)this.findViewById(R.id.watch); cmd_watchme.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setContentView(R.layout.tvvideo); VideoView video=(VideoView)findViewById(R.id.VideoView); MediaController mediaController = new MediaController(andy.this); mediaController.setAnchorView(video); video.setMediaController(mediaController); video.setVideoURI(videopath); video.start(); } }); After the video is displayed I am trying to get the backbutton on the phone itself to take the user back to the four button selection activity, listen, bio, ringtone, and watch. Question is, how do i do this? I was figuring if there was a way to change the ContentView after the video is displayed back to the main one for the four button page but could not figure it out. When I press the backbutton on the device, it takes me two levels up to the main selection activity not the four button activity. I hope this was somewhat clear. Thanks for any help.

    Read the article

  • I need to recover an instance of an activity

    - by Bilthon
    Well.. the title is pretty descriptive, I have a bunch of tab activities (which I implemented myself, didn't want to use the tabviews with activities inside them), so It's basically 5 activities calling each other every time the user clicks on the tabs displayed as a row of LinearLayouts at the bottom of the screen. The thing is that the way I do it now, everytime the user jumps from one activity to another, a new activity is created and launched. Of course, I can see I'm wasting resources this way. So what I would like to do is to create every activity only once; and then if the user wants to go back to the previous (or any one that was already created and is probably paused) just check on some kind of list or array to see if the activity can be recovered and only in the case it can't; to lauch a new one. My question is, how can I check this? should I save the intents? and how to recover the activities afterwards? I'm kind of new with java. Greetings Nelson R. Perez

    Read the article

  • Passing bundle to activity set as singletask

    - by Falmarri
    So I have a MapActivity that runs an asynchtask that occasionally updates what exactly it's displaying on the map (via a string). I originally pass this string in from the intent when the activity is first created. And then if you click on one of the drawables on the map, it opens a new activity, which can then create a new mapview (same class) with a different string setting. The problem I have is that I only want one instance of the mapview to be running at once. Thus I set android:launchmode="singletask" in the manifest. This works in that it brings the mapactivity to the front, but is there any way to send it a new intent bundle to get a new setting for the string it needs? I tried regetting the extras from the bundle, but it seems to retain the old bundle, not the new intent that was passed to it. I'm not sure I want to do startActivityForResult because the 2nd activity may or may not want to update the original activity. I hope that made sense. I can post code if necessary, but I think that should explain my situation.

    Read the article

  • Dismiss android activity displayed as Popup

    - by Sit
    So i have a service, that starts an activity displayed as a Popup thank's to "android:style/Theme.Dialog" This Activity shows a Listview, with a list of application. On each element of the listview, there is a short description of the application, and two buttons. 1 for launching the application 2 for displaying a toast with more informations. Here is the code in my service : it starts the activity Intent intent = new Intent(this, PopUpActivity.class); intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(intent); this activity uses a custom layout, with a listview, adapted with a custom ArrayAdapter In this adaptater, i've put an action on the start button in order to start the current application Button lanceur = (Button) v.findViewById(R.id.Buttonlancer); lanceur.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { p.start(mcontext); } }); with p.start, i start the application. But now, if i press "back" from the application, i go back to the popup... and i can start another application. I don't want it to be possible. That's why i wish i could dismiss/destroy/finish my PopupActivity, but i can't manage to do it with the code i have.

    Read the article

  • Activity won't start a service

    - by Marko Cakic
    I m trying to start an IntentService from the main activity of y application and it won't start. I have the service in the manifest file. Here's the code: MainActivity public class Home extends Activity { private LinearLayout kontejner; IntentFilter intentFilter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); kontejner = (LinearLayout) findViewById(R.id.kontejner); intentFilter = new IntentFilter(); startService(new Intent(getBaseContext(), HomeService.class)); } } Service: public class HomeService extends IntentService { public HomeService() { super("HomeService"); // TODO Auto-generated constructor stub } @Override protected void onHandleIntent(Intent intent) { Toast.makeText(getBaseContext(), "TEST", Toast.LENGTH_LONG).show(); } } Manifest: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.salefinder" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".Home" android:label="@string/title_activity_home" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name=".HomeService" /> </application> <uses-permission android:name="android.permission.INTERNET"/> </manifest> How can I make it work?

    Read the article

  • Immediately starting a new activity from an activity

    - by HowsItStack
    When I was originally learning about Android a few months ago I swear I read something about a way to immediately launch an activity when starting a task. I am curious about this now because I need to display an intro screen on launch but I don't want the intro screen to be the root activity. Does anyone know if there is something like this and if not what is the best way to handle an intro screen? I tried googling for a few hours to find it but can't for the life of me. Thanks for the help.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >