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
Related
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
I've been following some tutorials on how to make an app with API.ai integrated with it. But so far, unlike the tutorials, it gives me an error when I apply the Recognition Engine. This is the code on my Manifest.
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import ai.api.AIConfiguration;
import ai.api.AIListener;
import ai.api.android.AIService;
import ai.api.model.AIError;
import ai.api.model.AIResponse;
import ai.api.model.Result;
import ai.api.ui.AIButton;
public class MainActivity extends AppCompatActivity implements AIListener{
private AIService aiService;
TextView t;
#Override
protected void onCreate(Bundle savedInstanceState) {
AIService aiService;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t=findViewById(R.id.textView);
int permission = ContextCompat.checkSelfPermission(this,
Manifest.permission.RECORD_AUDIO);
if (permission != PackageManager.PERMISSION_GRANTED) {
makeRequest();
}
final AIConfiguration config = new AIConfiguration("CLIENT_ACCESS_TOKEN",
AIConfiguration.SupportedLanguages.English,
AIConfiguration.RecognitionEngine.System);
aiService = AIService.getService(this, (ai.api.android.AIConfiguration) config);
aiService.setListener(this);
}
This line of code: AIConfiguration.RecognitionEngine.System);
I have all the dependencies that API.ai requests to add to the app gradle.
It says "Cannot resolve the symbol". Does anyone know why this error occurs or how to fix it?
You need to add "import ai.api.android.AIConfiguration;"
I am trying to code an action bar for my android app and i defined my object to set the logo of the action bar to the default andorid icon before i update. When i run just that code, i get an error on the marked line.
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
public class myabDemo extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_myab_demo);
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setLogo(R.drawable.ic_launcher); // ***Error appears here***
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
}
It's not R.drawable.icon_launcher but R.drawable.ic_launcher (At least i'm pretty sure you followed the tutorial that puts ic_launcher and not icon_launcher)
I guess you received a nullpointer exception, since actionBar is null.
Add the code below:
requestWindowFeature(Window.FEATURE_NO_TITLE);
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?
hey i am new to android development. i tried exporting my app the process failed because of some minor errors and then i got errors all over my code. it was working perfectly fine with no errors before attempting to export.
check these two pics of the xml files where the errors popped up
main activity file: http://postimg.org/image/4gwdipnap/
second activity file: http://postimg.org/image/vuy1ryba3/
I didn't have any of these errors before trying to export the project.
heres the code for both of the files
main activity page
package youngadults.camden;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
public class FrontPage extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.front_page);
findViewById(R.id.uyounadults).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent myIntent = new Intent(FrontPage.this, youngadultsp.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(myIntent);
}
});
}
}
second activity page
package youngadults.camden;
import android.app.Activity;
import android.os.Bundle;
public class youngadultsp extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.youngadultsp_1);
}
}
You need to set Android API level, do you use Android Studio or Eclipse?
For Eclipse edit your Manifest file (19 is example):
<uses-sdk android:minSdkVersion="19" />
For Android Studio
Right click the App directory
Select "Open Module Setting" at the bottom
Under Modules select app
Set 'Compile Sdk version' as you want