the monitor of Android Studio do not show Logs.
I have the code:
package com.nv.threadpassdata;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import android.content.Context;
import com.google.android.material.snackbar.Snackbar;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "START";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, "Start");
}
}
And the monitor shows NOTHING:
In settings the Log ticks are ON.
I do not use emulator. Instead of emulator I connect my Phone (HUAWEI MYA-L41)
What is the problem? Can anybody find?
Thanks,
Nickolas
Try to do on of the following:
File>Invalidate Caches and Restart
Build>Clean Project then Build>Rebuild Project
Related
I can't open my app by clicking on a notification in OneSignal if the app is closed.
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import com.onesignal.OneSignal;
public class Loader extends AppCompatActivity {
private static final String ONESIGNAL_APP_ID = "xxxx-xxxx-xxxx-xxxx";//my app id instead of "xxxx"
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Enable verbose OneSignal logging to debug issues if needed.
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE);
// OneSignal Initialization
OneSignal.initWithContext(this);
OneSignal.setAppId(ONESIGNAL_APP_ID);
}
}
manifest contains:
<meta-data
android:name="com.onesignal.NotificationOpened.DEFAULT"
android:value="DISABLE"
/>
Gradle files like in onesignal sdk setup tutorial https://documentation.onesignal.com/docs/android-sdk-setup
ParseApplication firstly adding keys to ParseApplication.java is good but after sdk test show error in device "unfortunately, parseStarterProject has stopped work"
this is my ParseApplication.java file
package com.parse.starter;
import android.app.Application;
import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseCrashReporting;
import com.parse.ParseObject;
import com.parse.ParseUser;
public class ParseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
// Initialize Crash Reporting.
ParseCrashReporting.enable(this);
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
// Add your initialization code here
//copy and paste frome parse.com
// Parse.initialize(this, YOUR_APPLICATION_ID, YOUR_CLIENT_KEY);
Parse.initialize(this, "oaXYWiKShMVJ0VqZ52zwVnzpNlC3CKEReLV5wANX", "BiHRJalzAGYgFmh250SDxBxxi8DaIdnsnfunBfpC");
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// Optionally enable public read access.
// defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
}
}
Another, ParseStarterProjectActivity.java file is
package com.parse.starter;
import android.app.Activity;
import android.os.Bundle;
import com.parse.ParseAnalytics;
public class ParseStarterProjectActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ParseAnalytics.trackAppOpenedInBackground(getIntent());
}
}
this is doing in android studio and it's a starting project of parse.com "get start project"
if you are using android studio as a working environment....then what you just need is exit the android studio and then again open it and run your project it solve my problem......I think your will also help likewise.
Remove ParseUser.enableAutomaticUser(); from your code then try again?
I am new for the android apps developing, I have created an sample app with a html design included with it.
when i was trying to install the app it displays
"The application has stopped unexpectedly. Please try again" in the device.
Please help me. Thanks in Advance.
MainActivity.java:
package com.example.ship;
import android.net.ConnectivityManager;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.Toast;
import com.phonegap.*;
public class MainActivity extends DroidGap {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
super.init();
super.loadUrl("ship/assets/www/ship/task.html");
}
}
Try this,
super.loadUrl("file:///android_asset/www/ship/task.html");
Hoping to get into android app development so I'm doing some basic tutorials just now.
Just trying to get comfortable with the basics at the moment, one of which is using the Typeface class.
package org.me.myandroidstuff;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Typeface;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class HelloWorldActivity extends Activity implements OnClickListener
{
private View mainView;
private TextView tbox1;
private Button exitButton;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainView=(View)findViewById(R.id.mainView);
mainView.setBackgroundColor(getResources().getColor(R.color.silver));
tbox1 = (TextView)findViewById(R.id.textBox1);
tbox1.setTypeface(Typeface.MONOSPACE);
}
}
The line
tbox1 = (TextView)findViewById(R.id.textBox1);
Has a red cross beside it (I'm using eclipse) with the error
tbox1 cannot be resolved
Its been a while since i have used java, but as i aware the following code
create a new TextView object called tbox1
Assigns the tbox1 object the id specified in the xml for the TextView tag in an external main.xml
Then tbox1 executes the setTypeFace() method on itself?
Obviously I'm going wrong somewhere, any ideas? Something really simple no doubt...
You can't inform us about one error and neglect the others. Look at your code.
Besides what user370305 said, you have other problems. Namely, your Activity, according to the contract, implements OnClickListener but does not override the necessary onClick(View v) method. You must add it for the contract to be met.
So your code should look like:
package org.me.myandroidstuff;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class HelloWorldActivity extends Activity implements OnClickListener {
private View mainView;
private TextView tbox1;
private Button exitButton;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainView=(View)findViewById(R.id.mainView);
mainView.setBackgroundColor(getResources().getColor(R.color.silver));
tbox1 = (TextView)findViewById(R.id.textBox1);
tbox1.setTypeface(Typeface.MONOSPACE);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
Remember, you can't talk about errors until you fix every other that might cause other errors to be falsely reported.
First try to set setContentView(R.layout.yourlayoutfilename); in onCreate().
1.) Delete line super.onCreate(savedInstanceState);
2.) Retype super.onCreate(savedInstanceState);
3.) Clean the Project
4.) Build the Project
I don't know if it's possible but in my app I got an activity that show a phone number (retrieve from the web).
Can I send this number to the main phone app of android? For example to call it or save it?
You can create a tel:... Uri, where the ... is replaced by your phone number, then use that Uri with ACTION_DIAL or ACTION_CALL. For example:
package com.commonsware.android.dialer;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class DialerDemo extends Activity {
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
}
public void dial(View v) {
EditText number=(EditText)findViewById(R.id.number);
String toDial="tel:"+number.getText().toString();
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(toDial)));
}
}
The code shown above is from this sample project.