I'm just new to android development & I'm facing the problem
I grabbed listview from php/json (mysql output) into android device & its working fine.
For notifications I searched a lot and found GCM is good but bit complicated for me as a started.
I got some easy thing done with Parse Notifications (www.parse.com)
But the problem is, when i put Parse initialize lines in my listview code, the app crashes on pushing notification
here is code for my listview
ListView Code
I also tried to put Parse code in service, but still on receiving notification application crashes
and here is how I put parse lines in listview code
protected void onCreate(Bundle savedInstanceState) {
Parse.initialize(this, "ctMEM5bnp9OBIgiewrsxewq2IGVGt5NEdH7zaD4TCAd", "zX9pmbsadfsdacwezzC18XDXE16O1j0rdlOfCHzbdayS");
PushService.setDefaultPushCallback(this, MainActivity.class);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.listView1);
accessWebService();
}
Please can someone bing these two lines with my listview in manner they won't crash
Parse.initialize(this, "ctMEM5bnp9OBIgiewrsxewq2IGVGt5NEdH7zaD4TCAd", "zX9pmbsadfsdacwezzC18XDXE16O1j0rdlOfCHzbdayS");
PushService.setDefaultPushCallback(this, MainActivity.class);
You should create separate class Application that extends Application and put it in manifest
import com.parse.Parse;
import com.parse.ParseInstallation;
import com.parse.PushService;
public class Application extends android.app.Application {
public Application() {
}
#Override
public void onCreate() {
super.onCreate();
// Initialize the Parse SDK.
Parse.initialize(this, "YOUR_APP_ID", "YOUR_CLIENT_KEY");
// Specify an Activity to handle all pushes by default.
PushService.setDefaultPushCallback(this, MainActivity.class);
}
}
Manifiest:
<application android:name="com.parse.tutorials.pushnotifications.Application"
See this complete example: Github
Related
My problem is exactly like this link but it's not in android.
I have one button on a layout and two buttons on an another one. On my application, ClickScreen activity can be triggered by either FirstCase activity or SecondCase activity.
I tried to make a conditional statement on my ClickScreen for which activity is triggered but couldn't handle it. I don't want to create two more classes to do this since it's not an efficient technique.
private void goTo2ndPage() {
Intent i3 = new Intent(this, ClickScreen.class);
startActivity(i3);
}
public class ClickScreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.click_screen);
}
}
As we discussed in comments. It looks like what you really want is to add extra data in your intent so that Started Activity can get it and act accordingly.
Check out this post !
I have a problem, i want to send a parameter (int) from an app of build in android studio and receive it in an app build it in unity.
The apps work like this, you open the android app, press a botom and open the second app, i send and intent when i open the unity app but idkhow to recieve the param.
I know that are some questions about this but didn't work or maybe idk how to implement it to my code.
This is how i send the param
Java app
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.bodyar");
if(user!=null){
launchIntent.putExtra(Constant.TYPE,user.getLearningStyleId());
}else{
launchIntent.putExtra(Constant.TYPE,Constant.VISUAL);
}
startActivity(launchIntent);
but i dont know how to receive the value. I tried the stuff of UnityPlayer.UnitySendMessage(), but u just get an error from that
And the funciton of the Script that it´s attached to GameObjectUI is this
public void TipoTest(string token){
prueba.text = token;
}
And when i export the unity project to android, in the method OnCreate I recieve the params like this
public class UnityPlayerActivity extends Activity {
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
// Setup activity layout
#Override protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
mUnityPlayer = new UnityPlayer(this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
}
#Override protected void onNewIntent(Intent intent) {
// To support deep linking, we need to make sure that the client can get access to
// the last sent intent. The clients access this through a JNI api that allows them
// to get the intent set on launch. To update that after launch we have to manually
// replace the intent with the one caught here.
setIntent(intent);
}
}
And It works but idk how to pass the variable to unity script
I am a fairly new to android development, and I don't understant how the main class works on Android Studio.
I'm trying to make my app have the Crashlytics and Parse services but I'm not sure where to put them. Currently I have the code on the OnCreate method in the Login Class:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
Parse.initialize(this, "CODE", "CODE");
ParseInstallation.getCurrentInstallation().saveInBackground();
}
But I heard that this code should go on the Application Class... That's because the Application Class is always started and its basically the main Class for the app... I am not sure about this, please correct me if I'm wrong.
If that's the case, how can I access the Application Class and where should I put the code?
Just create a class which should extends the Application , Using this you can initialize the parse installation
public class DemoClass extends Application {
#Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
Parse.initialize(this, "CODE", "CODE");
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
Copy this above code
I am building an Android app using Eclipse and Android SDK.
I would like to implement an NFC p2p function in my app in the sense that when you place the 2 phones back to back, both send a string and receive a string automatically. This would of course happen in a separate activity. I have managed to send a custom tag (String) but have been unable to intercept it and use it afterwards in the app code. How can i do this?
This is what i have so far.
public class MainActivity extends Activity {
public NfcAdapter mAdapter;
PendingIntent mPendingIntent;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAdapter = NfcAdapter.getDefaultAdapter(this);
NdefRecord rec = NdefRecord.createUri("www.stackoverflow.com");
NdefMessage ndef = new NdefMessage(rec);
mAdapter.setNdefPushMessage(ndef, this);
}
I have spent a lot of time trying to find and understand solutions to intercept the tag. Unsuccessfully.
Thank you for your help.
New to Android so bear with me.
I have a fragment (DirectionsFragment) that calls an Activity to get some data from Yelp (YelpActivity).
When I run the YelpActivity itself, without calling it from DirectionsFragment, it runs succesfully (displays the received information, prints out appropriate log messages, etc.).
However, when I create YelpActivity from the fragment, nothing happens - no log messages, no retrieved information.
Here's how I create the YelpActivity
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
YelpActivity ya = new YelpActivity();
}
Thanks
Activity is started by startActivtiy(intent). But you have
YelpActivity ya = new YelpActivity();
Should not create an instance of Activity class.
Use
startActivity(new Intent(getActivtiy(),YealpActivtiy.class);
Make sure you have declared the activity in manifest file