
Java-android-chyba v Trace-oprava??
Mam chybu někde v MainActivity, ale nevim kde, a hledání pomocí googlu nepomohlo, když tam radili řešení, tak jsem to tam bud měl, nebo to nepomohlo... nějaké vaše rady???
Log: error opening trace file: No such file or directory (2)
__________________________________________________ ______________________________
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
Boolean isInternetPresent = false;
ConnectionDetector cd;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1 = (Button) findViewById(R.id.button1);
// creating connection detector class instance
cd = new ConnectionDetector(getApplicationContext());
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// get Internet status
isInternetPresent = cd.isConnectingToInternet();
// check for Internet status
if (isInternetPresent) {
// Internet Connection is Present
// make HTTP requests
showAlertDialog(MainActivity.this, "Internet Connection",
"You have internet connection", true);
} else {
// Internet connection is not present
// Ask user to connect to Internet
showAlertDialog(MainActivity.this, "No Internet Connection",
"You don't have internet connection.", false);
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
/** Called when the user clicks the check connection button */
public void checkConnection(View view) {
}
public void showAlertDialog(Context context, String title, String message, Boolean status) {
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// Setting Dialog Title
alertDialog.setTitle(title);
// Setting Dialog Message
alertDialog.setMessage(message);
// Setting alert dialog icon
alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int which) {
}
});
// Showing Alert Message
alertDialog.show();
}
}
Možná ti v návrhu aktivity nesedí názvy souborů.
taky jsou zkoušel hledat....a nenašel jsem...a eclipse natohle býva pomerne chytrý...
ono ti ten projekt nejde přeložit, nebo ti to nezobrazuje logovací informace na konzolu?
když se zapne tato třída, tak hned na začátku to vyhodí tenhle error
prý metoda show alert dialog je zastaralá,...nevíš jak poupravit?
Zkus použít AlertDialog.Builder
http://www.mkyong.com/android/android-alert-dialog -example/