remove unnecessary Runnable in onCreate()
onCreate is already running on the UI thread, no need to create a separate runnable.
This commit is contained in:
@@ -105,28 +105,21 @@ public class ListenActivity extends Activity
|
||||
|
||||
setContentView(R.layout.activity_listen);
|
||||
|
||||
ListenActivity.this.runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
NotificationCompat.Builder mBuilder =
|
||||
new NotificationCompat.Builder(ListenActivity.this)
|
||||
.setOngoing(true)
|
||||
.setSmallIcon(R.drawable.listening_notification)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(R.string.listening));
|
||||
NotificationCompat.Builder mBuilder =
|
||||
new NotificationCompat.Builder(ListenActivity.this)
|
||||
.setOngoing(true)
|
||||
.setSmallIcon(R.drawable.listening_notification)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(R.string.listening));
|
||||
|
||||
_mNotifyMgr.notify(mNotificationId, mBuilder.build());
|
||||
|
||||
_mNotifyMgr.notify(mNotificationId, mBuilder.build());
|
||||
final TextView connectedText = (TextView) findViewById(R.id.connectedTo);
|
||||
connectedText.setText(_name);
|
||||
|
||||
final TextView connectedText = (TextView) findViewById(R.id.connectedTo);
|
||||
connectedText.setText(_name);
|
||||
final TextView statusText = (TextView) findViewById(R.id.textStatus);
|
||||
statusText.setText(R.string.listening);
|
||||
|
||||
final TextView statusText = (TextView) findViewById(R.id.textStatus);
|
||||
statusText.setText(R.string.listening);
|
||||
}
|
||||
});
|
||||
|
||||
_listenThread = new Thread(new Runnable()
|
||||
{
|
||||
|
||||
@@ -167,30 +167,24 @@ public class MonitorActivity extends Activity
|
||||
});
|
||||
_serviceThread.start();
|
||||
|
||||
MonitorActivity.this.runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final TextView addressText = (TextView) findViewById(R.id.address);
|
||||
final TextView addressText = (TextView) findViewById(R.id.address);
|
||||
|
||||
// Use the application context to get WifiManager, to avoid leak before Android 5.1
|
||||
final WifiManager wifiManager =
|
||||
(WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
final WifiInfo info = wifiManager.getConnectionInfo();
|
||||
final int address = info.getIpAddress();
|
||||
if(address != 0)
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
final String ipAddress = Formatter.formatIpAddress(address);
|
||||
addressText.setText(ipAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
addressText.setText(R.string.wifiNotConnected);
|
||||
}
|
||||
|
||||
// Use the application context to get WifiManager, to avoid leak before Android 5.1
|
||||
final WifiManager wifiManager =
|
||||
(WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
final WifiInfo info = wifiManager.getConnectionInfo();
|
||||
final int address = info.getIpAddress();
|
||||
if(address != 0)
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
final String ipAddress = Formatter.formatIpAddress(address);
|
||||
addressText.setText(ipAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
addressText.setText(R.string.wifiNotConnected);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user