Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Servus Jungs,

ich hab ne kleine App, die im Hintergrund Zahlen hochzählt (Als eine Art Timer).

Vorab: Ja ich weiss, ich könnte auch den Aktuellen Zeitstempel Nehmen und hochrechnen. Aber man kann das Datum / Die Uhrzeit verändern. Das will ich nicht.

Außerdem soll Später im Sekundentakt auch was anderes passieren im Hintergrund (z.B. GPS Positionen übermitteln für eine Ortungssoftware). Nein, ich mach das nicht unerlaubt. Das ist für mich selber.

Jedenfalls hab ich das mal verkleinert und ein Label gemacht, dass einfach den Freien Speicher anzeigt.


public void StartClick(View v)

    {

		TextView view = (TextView)findViewById(R.id.lblFreeSpace);

		new AppendFileThread(v);



		Thread th = new Thread(new Runnable()

		{

	        public void run() {

	            while (true)

	            {                

	                runOnUiThread(new Runnable() {

	                    @Override

	                    public void run()

	                    {

	            			long availableSpace = -1L;

	            		    StatFs stat = new StatFs(Environment.getDataDirectory().getPath());

	            		    availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();

	            		    TextView lbl = (TextView)findViewById(R.id.lblFreeSpace);

	            		    lbl.setText(String.valueOf(availableSpace));

	                    }

	                });

	                try {

	                    Thread.sleep(500);

	                } 

	                catch (InterruptedException e) {

	                    e.printStackTrace();

	                }

	            }

	        }

	    });

	    th.start();

    }

Wenn die App im Hintergrund läuft, wird die nach ner Zeit beendet.

Wie kann ich das verhindern?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.