Search Results

Search found 121 results on 5 pages for 'onstart'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • Android: Using onStart() method in Bluetooth application

    - by Nii
    Hello, I am getting a nullpointer exception when my onStart() method is called. Here is the breakdown of my Android app: Opening the app brings a user to the homescreen: The user is then presented with the first 6 icons to choose from. When the user presses the "Sugar" icon it takes them to the SugarTabActivity. The SugarTabActivity is a Tabbed layout with two tabs. I'm concerned with the first tab. The first tab calls the getDefaultAdapter() method in its onCreate() method. Once it calls this, it checks if the bluetooth adapter is null on the phone, and if its null it shows a toast saying "Bluetooth is not available". This works just fine. Then I call the onStart() method. In the onStart() method I check if bluetooth is enabled, and if it isnt, then I start a new activity from the BluetoothAdapter enable bluetooth intent; otherwise, I start my bluetooth service. The exact error I'm getting is 04-19 00:44:45.674: ERROR/AndroidRuntime(225): Caused by: java.lang.NullPointerException 04-19 00:44:45.674: ERROR/AndroidRuntime(225): at com.nii.glucose.Glucose.onStart(Glucose.java:313). Heading Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if(D) Log.d(TAG, "+++ ON CREATE +++"); setContentView(R.layout.glucose_layout); mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if(mBluetoothAdapter==null){ Toast.makeText(this, "Bluetooth not available", Toast.LENGTH_LONG).show(); //finish(); return; } } Override public void onStart() { super.onStart(); if(D) Log.e(TAG, "++ ON START ++"); // If BT is not on, request that it be enabled. // setupChat() will then be called during onActivityResult if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); // Otherwise, setup the chat session } else { if (mGlucoseService == null) mGlucoseService = new BluetoothService(this, mHandler); } } @Override public synchronized void onResume(){ super.onResume(); if(D) Log.e(TAG,"==== ON RESUME ======"); // Performing this check in onResume() covers the case in which BT was // not enabled during onStart(), so we were paused to enable it... // onResume() will be called when ACTION_REQUEST_ENABLE activity returns. if (mGlucoseService != null) { // Only if the state is STATE_NONE, do we know that we haven't started already if (mGlucoseService.getState() == BluetoothService.STATE_NONE) { // Start the Bluetooth chat services mGlucoseService.start(); } } } @Override public synchronized void onPause(){ super.onPause(); //isActive.set(false); if(D) Log.e(TAG,"==== ON PAUSE ======"); } @Override public void onDestroy() { super.onDestroy(); // Stop the Bluetooth chat services if (mGlucoseService != null) mGlucoseService.stop(); if(D) Log.e(TAG, "--- ON DESTROY ---"); }

    Read the article

  • @OnStart & @OnStop

    - by Geertjan
    In applications based on NetBeans Platform 7.2, you'll be able to replace all your ModuleInstall classes with this code: import org.openide.modules.OnStart; import org.openide.modules.OnStop; @OnStart public final class Installer implements Runnable { @Override public void run() { System.out.println("enable something..."); } @OnStop public static final class Down implements Runnable { @Override public void run() { System.out.println("disable something..."); } } } Build the module and the annotations result in named services, thanks to @NamedServiceDefinition: Aside from no longer needing to register the ModuleInstall class in the manifest, performance of startup will be enhanced, if you use the above approach: https://netbeans.org/bugzilla/show_bug.cgi?id=200636

    Read the article

  • Android lifecycle: Fill in data in activity in onStart() or onResume()?

    - by pjv
    Should you get data via a cursor and fill in the data on the screen, such as setting the window title, in onStart() or onResume()? onStart() would seem the logical place because after onStart() the Activity can already be displayed, albeit in the background. Notably I was having a problem with a managed dialog that made me rethink this. If the user rotates the screen while the dialog is still open, onCreateDialog() and onPrepareDialog() are called between onStart() and onResume(). If the dialog needs to be based on the data you need to have the data before onResume(). If I'm correct about onStart() then why does the Notepad example give a bad example by doing it in onResume()? See http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NoteEditor.html NoteEditor.java line 176 (title = mCursor.getString...). Also, what if my Activity launches another Actvity/Dialog that changes the data my cursor is tracking. Even in the simplest case, does that mean that I have to manually update my previous screen (a listener for a dialog in the main activity), or alternatively that I have to register a ContentObserver, since I'm no longer updating the data in onResume() (though I could update it twice of course)? I know it's a basic question but the dialog only recently, to my surprise, made me realize this.

    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 Service onBind -> onStart

    - by Gernot
    Hello, I have a comprehension question about Android Services. I have a Service that performs background http operations and a Activity that should display the current state of these http operations. So I implementet the Binder interface and so on. I can call the bindService method and onServiceConnected of my ServiceConnnection is getting called. But as far as I know, onBind doesn't calls onStartCommand() and so onStart() of the Service is never called. So how can I call the onStart() method of the service class and start my operations. Or how is the best way to start my operations in the service, when I also want a binding between the Activity and the Service.

    Read the article

  • "Scheduling restart of crashed service", but no call to onStart() follows

    - by kostmo
    In the 1.6 API, is there a way to ensure that the onStart() method of a Service is called after the service is killed due to memory pressure? From the logs, it seems that the "process" that the service belongs to is restarted, but the service itself is not. I have placed a Log.d() call in the onStart() method, and this is not reached. To test my service under memory pressure, I spawn it from an activity, then launch the web browser and visit some Javascript-heavy websites like Slashdot until my service is killed. The logcat reads: 03-07 16:44:13.778: INFO/ActivityManager(52): Process com.kostmo.charbuilder.full (pid 2909) has died. 03-07 16:44:13.778: WARN/ActivityManager(52): Scheduling restart of crashed service com.kostmo.charbuilder.full/com.kostmo.charbuilder.DownloadImagesService in 5000ms 03-07 16:44:13.778: INFO/ActivityManager(52): Low Memory: No more background processes. 03-07 16:44:13.778: ERROR/ActivityThread(52): Failed to find provider info for android.server.checkin 03-07 16:44:13.778: WARN/Checkin(52): Can't log event SYSTEM_SERVICE_LOOPING: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/events 03-07 16:44:18.908: INFO/ActivityManager(52): Start proc com.kostmo.charbuilder.full for service com.kostmo.charbuilder.full/com.kostmo.charbuilder.DownloadImagesService: pid=3560 uid=10027 gids={3003, 1015} 03-07 16:44:19.868: DEBUG/ddm-heap(3560): Got feature list request 03-07 16:44:20.128: INFO/ActivityThread(3560): Publishing provider com.kostmo.charbuilder.full.provider.character: com.kostmo.charbuilder.provider.ImageFileContentProvider

    Read the article

  • what is the right way to exit Windoes Service OnStart if configuration is wrong and nothing to do in

    - by matti
    Is something like this ok? protected override void OnStart(string[] args) { if (SomeApp.Initialize()) { SomeApp.StartMonitorAndWork(); base.OnStart(args); } } protected override void OnStop() { SomeApp.TearDown(); base.OnStop(); } Here Initialize reads a config file and if it's wrong there's nothing to do so service should STOP! If config is ok StartMonitorAndWork starts: Timer(new TimerCallback(DoWork), null, startTime, loopTime); and DoWork polls database periodically. The question is: "Is exiting OnStart without doing nothing enough if Initialize returns false? OR should there be something like this: private void ExitService() { this.OnStop(); System.Environment.Exit(1); } protected override void OnStart(string[] args) { if (ObjectFolderApp.Initialize()) { SomeApp.StartMonitorAndWork(); base.OnStart(args); } else { ExitService(); } } Thanks & BR - Matti

    Read the article

  • destroy an android service

    - by Jack Trowbridge
    I am using a service in my android app, which is called when an alarm is activated by a calander. When the service has been activated i want it to be destroyed by the OnStart() method once it has completed its code. My OnStart() method: @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Vibrator vi = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vi.vibrate(5000); Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG).show(); //CODE HERE TO DESTROY SERVICE?? } This bassically means when the service is called it runs the code in the OnStart() method and i want it to destroy itself. Any Ideas, methods that would do this?. Thanks, jack.

    Read the article

  • How can I utilize or mimic Application OnStart in an HttpModule?

    - by Sailing Judo
    We are trying to remove the global.asax from our many web applications in favor of HttpModules that are in a common code base. This works really well for many application events such as BeginRequest and PostAuthentication, but there is no Application Start event exposed in the HttpModule. I can think of a couple of smelly ways to overcome this deficit. For example, I can probably do this: protected virtual void BeginRequest(object sender, EventArgs e) { Log.Debug("Entered BeginRequest..."); var app = HttpContext.Current.Application; var hasBeenSet app["HasBeenExecuted"] == null ? false : true; if(!hasBeenSet) { app.Lock(); // ... do app level code app.Add("HasBeenSet", true); app.Unlock(); } // do regular begin request stuff ... } But this just doesn't smell well to me. What is the best way to invoke some application begin logic without having a global.asax?

    Read the article

  • Use a Cursor field in another method

    - by Mats Hofman
    Hi, In my app i have have a Cursor field and in the onStart() method of my Android Service I create it by fetching records from my database. When i look into my cursor in the onStart() method i find a number of records but when i try to use them in my trigger() method it has zero records. the field private Cursor c; in onStart() c = dbHelper.fetchAllRecords(); in trigger() c.getCount() returns null I didn't close the cursor earlier than in my onDestroy() method

    Read the article

  • Android: Dialog themed activity not visible

    - by Vincent
    I have an activity which, when started, needs to check if the user is authenticated. If not, I need to display an interface to authenticate. I do this with another activity, which has a dialog theme, and I start it in onResume() with flags NO_HISTORY and EXCLUDE_FROM_RECENTS. Everything works fine when starting the application for the first time. But I have a feature that resets login after some time, if the user is not in an activity. When I test this, I start the applicatio, enter the password, then move back to home. Then when I enter the application again, the background darkens as if the dialog would show, but it doesn't. At this point, if I press the back button, the darkening from the background activity disappears for a second, then the dialog finally appears. I used logcat to investigate the case, and the activity lifecycle functions get called properly: //For the first start: onCreate background activity onStart background activity onResume background activity onPause background activity onCreate dialog onStart dialog onResume dialog //Enter password onPause dialog onResume background activity onStop dialog onDestroy dialog //navigating to homescreen onPause background activity onStop background activity //starting again onRestart background activity onStart background activity onResume background activity onPause background activity onCreate dialog onStart dialog onResume dialog //no dialog shown, only darkened background activity recieving no input //pressing back button onPause dialog onResume background activity onPause background activity onCreate NEW dialog onStart NEW dialog onResume NEW dialog onStop OLD dialog onDestroy OLD dialog //now the dialog is properly shown //entering password onPause NEW dialog onResume background activity onStop NEW dialog onDestroy NEW dialog Using the SINGLE_TOP flag makes no change. However, if I remove the dialog theme from the dialog activity, it IS shown after the restart. So far I didn't want to use a Dialog instead of an Activity, because I consider them problematic sometimes and less encapsulated and this part has to be quite secure. You may be able to convince me though.. Thank you in advance!

    Read the article

  • MessageQueue.BeginReceive() null ref error - c#

    - by ltech
    Have a windows service that listens to a msmq. In the OnStart method is have this protected override void OnStart(string[] args) { try { _queue = new MessageQueue(_qPath);//this part works as i had logging before and afer this call //Add MSMQ Event _queue.ReceiveCompleted += new ReceiveCompletedEventHandler(queue_ReceiveCompleted);//this part works as i had logging before and afer this call _queue.BeginReceive();//This is where it is failing - get a null reference exception ; } catch(Exception ex) { EventLogger.LogEvent(EventSource, EventLogType, "OnStart" + _lineFeed + ex.InnerException.ToString() + _lineFeed + ex.Message.ToString()); } } where private MessageQueue _queue = null;

    Read the article

  • Solved::MessageQueue.BeginReceive() null ref error - c#

    - by ltech
    Have a windows service that listens to a msmq. In the OnStart method is have this protected override void OnStart(string[] args) { try { _queue = new MessageQueue(_qPath);//this part works as i had logging before and afer this call //Add MSMQ Event _queue.ReceiveCompleted += new ReceiveCompletedEventHandler(queue_ReceiveCompleted);//this part works as i had logging before and afer this call _queue.BeginReceive();//This is where it is failing - get a null reference exception } catch(Exception ex) { EventLogger.LogEvent(EventSource, EventLogType, "OnStart" + _lineFeed + ex.InnerException.ToString() + _lineFeed + ex.Message.ToString()); } } where private MessageQueue _queue = null; This works on my machine but when deployed to a windows 2003 server and running as Network service account, it fails Exception recvd: Service cannot be started. System.NullReferenceException: Object reference not set to an instance of an object. at MYService.Service.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) Solved: Turned out that the Q that i set up, I had to explicitly add Network Service account to it under security tab

    Read the article

  • How can i use ClearCanvas in remote database?

    - by programmerist
    How can i get data from REMOTE database using OnStart method? protected override int OnStart(StudyLoaderArgs studyLoaderArgs) { ApplicationEntity ae = studyLoaderArgs.Server as ApplicationEntity; _ae = ae; EventResult result = EventResult.Success; AuditedInstances loadedInstances = new AuditedInstances(); try { XmlDocument doc = RetrieveHeaderXml(studyLoaderArgs); StudyXml studyXml = new StudyXml(); studyXml.SetMemento(doc); _instances = GetInstances(studyXml).GetEnumerator(); loadedInstances.AddInstance(studyXml.PatientId, studyXml.PatientsName, studyXml.StudyInstanceUid); return studyXml.NumberOfStudyRelatedInstances; } finally { AuditHelper.LogOpenStudies(new string[] { ae.AETitle }, loadedInstances, EventSource.CurrentUser, result); } } i need to use OnStart in main project. How cn i use or call OnStart method

    Read the article

  • Autoscaling in a modern world…. Part 4

    - by Steve Loethen
    Now that I have the rules and services XML files in the cloud, it is time to sever the bounds of earth and live totally in the cloud.  I have to host the Autoscaling object in Azure as well, point it to the rules, tell it the management certs and get out of the way. A couple of questions.  Where to host?  The most obvious place to me was a worker role.  A simple, single purpose worker role, doing nothing but watching my app.  Here are the steps I used. 1) Created a project.  Separate project from my web site.  I wanted to be able to run the web in the cloud and the autoscaler local for debugging purposes.  Seemed like the easiest way.  2) Add the Wasabi block to the project. 3) Configure the settings.  I used the same settings used for the console app.  It points to the same web role, uses the same rules file.  4) Make sure the certification needed to manage the role is added to the cert store in the sky (“LocalMachine” and “My” are default locations). I ran the worker role in the local fabric.  It worked.  I then published to the cloud, and verified it worked again.  Here is what my code looked like. public override bool OnStart() { Trace.WriteLine("Set Default Connection Limit", "Information"); // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; Trace.WriteLine("Set up configuration change code", "Information"); // set up config CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))); Trace.WriteLine("Get current diagnostic configuration", "Information"); // Get current diagnostic configuration DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration(); Trace.WriteLine("Set Diagnostic Buffer Size", "Information"); // Set Diagnostic Buffer size dmc.Logs.BufferQuotaInMB = 4; Trace.WriteLine("Set log transfer period", "Information"); // Set log transfer period dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1); Trace.WriteLine("Set log verbosity", "Information"); // Set log filter to verbose dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose; Trace.WriteLine("Start the diagnostic monitor", "Information"); // Start the diagnostic monitor DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", dmc); Trace.WriteLine("Get the current Autoscaler from the EntLib Container", "Information"); // Get the current Autoscaler from the EntLib Container scaler = EnterpriseLibraryContainer.Current.GetInstance<Autoscaler>(); Trace.WriteLine("Start the autoscaler", "Information"); // Start the autoscaler scaler.Start(); Trace.WriteLine("call the base class OnStart", "Information"); // call the base class OnStart return base.OnStart(); } public override void OnStop() { Trace.WriteLine("Stop the Autoscaler", "Information"); // Stop the Autoscaler scaler.Stop(); } I did have to turn on some basic logging for wasabi, which will cover in the next post.  This let me figure out that I hadn’t done the certificate step.

    Read the article

  • Battery drains even with app off screen, could it be Location Services doing it?

    - by John Jorsett
    I run my app, which uses GPS and Bluetooth, then hit the back button so it goes off screen. I verified via LogCat that the app's onDestroy was called. OnDestroy removes the location listeners and shuts down my app's Bluetooth service. I look at the phone 8 hours later and half the battery charge has been consumed, and my app was responsible according the phone's Battery Use screen. If I use the phone's Settings menu to Force Stop the app, this doesn't occur. So my question is: do I need to do something more than remove the listeners to stop Location Services from consuming power? That's the only thing I can think of that would be draining the battery to that degree when the app is supposedly dormant. Here's my onStart() where I turn on the location-related stuff and Bluetooth: @Override public void onStart() { super.onStart(); if(D_GEN) Log.d(TAG, "MainActivity onStart, adding location listeners"); // If BT is not on, request that it be enabled. // setupBluetooth() will then be called during onActivityResult if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); // Otherwise, setup the Bluetooth session } else { if (mBluetoothService == null) setupBluetooth(); } // Define listeners that respond to location updates mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_UPDATE_INTERVAL, 0, this); mLocationManager.addGpsStatusListener(this); mLocationManager.addNmeaListener(this); } And here's my onDestroy() where I remove them: public void onDestroy() { super.onDestroy(); if(D_GEN) Log.d(TAG, "MainActivity onDestroy, removing update listeners"); // Remove the location updates if(mLocationManager != null) { mLocationManager.removeUpdates(this); mLocationManager.removeGpsStatusListener(this); mLocationManager.removeNmeaListener(this); } if(D_GEN) Log.d(TAG, "MainActivity onDestroy, finished removing update listeners"); if(D_GEN) Log.d(TAG, "MainActivity onDestroy, stopping Bluetooth"); stopBluetooth(); if(D_GEN) Log.d(TAG, "MainActivity onDestroy finished"); }

    Read the article

  • Windows Azure RoleEntryPoint Method Call Order

    - by kaleidoscope
    Worker Role Call Order: WaWorkerHost process is started. Worker Role assembly is loaded and surfed for a class that derives from RoleEntryPoint.  This class is instantiated. RoleEntryPoint.OnStart() is called. RoleEntryPoint.Run() is called.  If the RoleEntryPoint.Run() method exits, the RoleEntryPoint.OnStop() method is called . WaWorkerHost process is stopped. The role will recycle and startup again. Web Role Call Order: WaWebHost process is started. Hostable Web Core is activated. Web role assembly is loaded and RoleEntryPoint.OnStart() is called. Global.Application_Start() is called. The web application runs Global.Application_End() is called. RoleEntryPoint.OnStop() is called. Hostable Web Core is deactivated. WaWebHost process is stopped. For Further Reference: http://blogs.msdn.com/jnak/archive/2010/02/11/windows-azure-roleentrypoint-method-call-order.aspx   Tinu, O

    Read the article

  • SurfaceView drawn on top of other elements after coming back from specific activity

    - by spirytus
    I have an activity with video preview displayed via SurfaceView and other views positioned over it. The problem is when user navigates to Settings activity (code below) and comes back then the surfaceview is drawn on top of everything else. This does not happen when user goes to another activity I have, neither when user navigates outside of app eg. to task manager. Now, you see in code below that I have setContentVIew() call wrapped in conditionals so it is not called every time when onStart() is executed. If its not wrapped in if statements then all works fine, but its causing loosing lots of memory (5MB+) each time onStart() is called. I tried various combinations and nothing seems to work so any help would be much appreciated. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Toast.makeText(this,"Create ", 2000).show(); // set 32 bit window (draw correctly transparent images) getWindow().getAttributes().format = android.graphics.PixelFormat.RGBA_8888; // set the layout of the screen based on preferences of the user sharedPref = PreferenceManager.getDefaultSharedPreferences(this); } public void onStart() { super.onStart(); String syncConnPref = null; syncConnPref = sharedPref.getString("screensLayouts", "default"); if(syncConnPref.contentEquals("default") && currentlLayout!="default") { setContentView(R.layout.fight_recorder_default); } else if(syncConnPref.contentEquals("simple") && currentlLayout!="simple") { setContentView(R.layout.fight_recorder_simple); } // I I uncomment line below so it will be called every time without conditionals above, it works fine but every time onStart() is called I'm losing 5+ MB memory (memory leak?). The preview however shows under the other elements exactly as I need memory leak makes it unusable after few times though // setContentView(R.layout.fight_recorder_default); if(getCamera()==null) { Toast.makeText(this,"Sorry, camera is not available and fight recording will not be permanently stored",2000).show(); // TODO also in here put some code replacing the background with something nice return; } // now we have camera ready and we need surface to display picture from camera on so // we instantiate CameraPreviw object which is simply surfaceView containing holder object. // holder object is the surface where the image will be drawn onto // this is where camera live cameraPreview will be displayed cameraPreviewLayout = (FrameLayout) findViewById(id.camera_preview); cameraPreview = new CameraPreview(this); // now we add surface view to layout cameraPreviewLayout.removeAllViews(); cameraPreviewLayout.addView(cameraPreview); // get layouts prepared for different elements (views) // this is whole recording screen, as big as screen available recordingScreenLayout=(FrameLayout) findViewById(R.id.recording_screen); // this is used to display sores as they are added, it displays like a path // each score added is a new text view simply and as user undos these are removed one by one allScoresLayout=(LinearLayout) findViewById(R.id.all_scores); // layout prepared for controls like record/stop buttons etc startStopLayout=(RelativeLayout) findViewById(R.id.start_stop_layout); // set up timer so it can be turned on when needed //fightTimer=new FightTimer(this); fightTimer = (FightTimer) findViewById(id.fight_timer); // get views for displaying scores score1=(TextView) findViewById(id.score1); score2=(TextView) findViewById(id.score2); advantages1=(TextView) findViewById(id.advantages1); advantages2=(TextView) findViewById(id.advantages2); penalties1=(TextView) findViewById(id.penalties1); penalties2=(TextView) findViewById(id.penalties2); RelativeLayout welcomeScreen=(RelativeLayout) findViewById(id.welcome_screen); Animation fadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in); welcomeScreen.startAnimation(fadeIn); Toast.makeText(this,"Start ", 2000).show(); animateViews(); } Settings activity is below, after coming back from this activity surfaceview is drawn on top of other elements. public class SettingsActivity extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(MyFirstAppActivity.getCamera()==null) { Toast.makeText(this,"Sorry, camera is not available",2000).show(); return; } addPreferencesFromResource(R.xml.preferences); } }

    Read the article

  • how to pass arguments to windows services in c#?

    - by eurekha_ananth
    I just want to know how to pass arguments to windows services . The problem is , i am developed a windows application and then called it from Onstart() method . Now , i want to call the particular function from another project . protected override void OnStart(string[] args) { Process.Start("C:\\Program Files\\macro.exe"); } I want to call a function inside the macro.exe project with arguments . Any suggestions

    Read the article

  • Android animation's first frame is applied too early on ImageView

    - by Robert
    I have the following View setup in one of my Activities: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/photoLayout" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/photoImageView" android:src="@drawable/backyardPhoto" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:scaleType="centerInside" android:padding="45dip" > </ImageView> </LinearLayout> Without an animation set, this displays just fine. However I want to display a very simple animation. So in my Activity's onStart override, I have the following: @Override public void onStart() { super.onStart(); mPhotoImageView = (ImageView) findViewById(R.id.photoImageView); float offset = -25; int top = mPhotoImageView.getTop(); TranslateAnimation anim1 = new TranslateAnimation( Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, top, Animation.ABSOLUTE, offset); anim1.setInterpolator(new AnticipateInterpolator()); anim1.setDuration(1500); anim1.setStartOffset(5000); TranslateAnimation anim2 = new TranslateAnimation( Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, offset, Animation.ABSOLUTE, top); anim2.setInterpolator(new BounceInterpolator()); anim2.setDuration(3500); anim2.setStartOffset(6500); mBouncingAnimation = new AnimationSet(false); mBouncingAnimation.addAnimation(anim1); mBouncingAnimation.addAnimation(anim2); mPhotoImageView.setAnimation(mBouncingAnimation); } The problem is that when the Activity displays for the first time, the initial position of the photo is not in the center of the screen with padding around. It seems like the first frame of the animation is loaded already. Only after the animation is completed, does the photoImageView "snap" back to the intended location. I've looked and looked and could not find how to avoid this problem. I want the photoImageView to start in the center of the screen, and then the animation to happen, and return it to the center of the screen. The animation should happen by itself without interaction from the user.

    Read the article

  • How to get at contents of placeholder::_1

    - by sheepsimulator
    I currently have the following code: using boost::bind; typedef boost::signal<void(EventDataItem&)> EventDataItemSignal; class EventDataItem { ... EventDataItemSignal OnTrigger; ... } typedef std::list< shared_ptr<EventDataItem> > DataItemList; typedef std::list<boost::signals::connection> ConnectionList; class MyClass { void OnStart() { DataItemList dilItems; ConnectionList clConns; DataItemList::iterator iterDataItems; for(iterDataItems = dilItems.begin(); iterDataItems != dilItems.end(); iterDataItems++) { // Create Connections from Triggers clConns.push_back((*iterDataItems)->OnTrigger.connect( bind(&MyClass::OnEventTrigger, this))); } } void OnEventTrigger() { // ... Do stuff on Trigger... } } I'd like to change MyClass::OnStart to use std::transform to achieve the same thing: void MyClass::OnStart() { DataItemList dilItems; ConnectionList clConns; // Resize connection list to match number of data items clConns.resize(dilItems.size()); // Build connection list from Items // note: errors on the placeholder _1->OnTrigger std::transform(dilItems.begin(), dilItems.end(), clConns.begin(), bind(&EventDataItemSignal::connect, _1->OnTrigger, bind(&MyClass::Stuff, this))); } However, my hiccup is _1-OnTrigger. How can I reference OnTrigger from placeholder _1?

    Read the article

1 2 3 4 5  | Next Page >