I'm trying to create a application, where you can buy In-App credits with the Fortumo service. I've managed to get the makePayment(); method working so I can make a payment and everything seems to work. The only thing is, that it looks like the onReceive(); is never called because the credits count is not changed after a successful payment. The credits count should be increased by 32000 with one payment of 0.32€.
Here is the main activity java:
package com.your.raha;
import com.your.raha.R;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
public class Soundboard extends Activity {
private SoundManager mSoundManager;
static int counter;
static TextView display;
SharedPreferences someData;
public static String filename = "rahafail";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
setContentView(R.layout.proov);
display = (TextView) findViewById(R.id.tvKonto);
someData = getSharedPreferences(filename, 0);
int returnedInt = someData.getInt("sharedInt", 0);
counter = returnedInt;
mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(1, R.raw.sound1);
Button SoundButton1 = (Button)findViewById(R.id.sound1);
SoundButton1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(1);
AddOne();
}
});
Button bOsta = (Button)findViewById(R.id.bOsta);
bOsta.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
onStop();
startActivity(new Intent("com.uugudev.rahaboss.FORTUMOMAKSA"));
}
});
ImageButton Abi = (ImageButton)findViewById(R.id.ibAbi);
Abi.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
counter = 0;
SharedPreferences.Editor editor = someData.edit();
editor.putInt("sharedInt", counter);
editor.commit();
display.setText(counter + " EEK");
}
});
}
public static void AddOne() {
// TODO Auto-generated method stub
counter++;
display.setText(counter + " EEK");
}
public static void Osteti() {
// TODO Auto-generated method stub
counter = counter + 32000;
display.setText(counter + " EEK");
}
#Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
SharedPreferences.Editor editor = someData.edit();
editor.putInt("sharedInt", counter);
editor.commit();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
SharedPreferences.Editor editor = someData.edit();
editor.putInt("sharedInt", counter);
editor.commit();
}
#Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
int returnedInt = someData.getInt("sharedInt", 0);
counter = returnedInt;
}
#Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
SharedPreferences.Editor editor = someData.edit();
editor.putInt("sharedInt", counter);
editor.commit();
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
display.setText(counter + " EEK");
}
}
The payment activity class:
package com.your.raha;
import android.os.Bundle;
import android.view.Window;
import android.widget.Toast;
import com.fortumo.android.Fortumo;
import com.fortumo.android.PaymentActivity;
import com.fortumo.android.PaymentRequestBuilder;
import com.fortumo.android.PaymentResponse;
public class FortumoMaksa extends PaymentActivity {
/** Called when the activity is first created. */
public int raha;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Fortumo.enablePaymentBroadcast(this, Manifest.permission.PAYMENT_BROADCAST_PERMISSION);
PaymentRequestBuilder builder = new PaymentRequestBuilder();
builder.setDisplayString("Donate");
builder.setProductName("stars_myawesomeusername");
makePayment(builder.build());
}
;
#Override
protected void onResume() {
super.onResume();
}
#Override
protected void onPaymentCanceled(PaymentResponse response) {
Toast.makeText(this, "Kasutaja katkestas makse", Toast.LENGTH_SHORT).show();
finish();
}
#Override
protected void onPaymentFailed(PaymentResponse response) {
Toast.makeText(this, "Makse ebaõnnestus", Toast.LENGTH_SHORT).show();
finish();
}
#Override
protected void onPaymentPending(PaymentResponse response) {
Toast.makeText(this, "Makse ootel", Toast.LENGTH_SHORT).show();
finish();
}
#Override
protected void onPaymentSuccess(PaymentResponse response) {
Toast.makeText(this, "Makse õnnestus", Toast.LENGTH_SHORT).show();
finish();
}
}
The PaymentStatusReceived class:
package com.your.raha;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.fortumo.android.Fortumo;
public class PaymentStatusReceiver extends BroadcastReceiver {
private static String TAG = "PaymentStatusReceiver";
#Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
int billingStatus = extras.getInt("billing_status");
if(billingStatus == Fortumo.MESSAGE_STATUS_BILLED) {
Soundboard.Osteti();
}
}
}
The AndroidManifest xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.your.raha"
android:installLocation="auto"
android:versionCode="2"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<permission
android:name="com.your.domain.PAYMENT_BROADCAST_PERMISSION"
android:label="Read Fortumo payment status"
android:protectionLevel="signature" />
<uses-permission android:name="com.your.raha.PAYMENT_BROADCAST_PERMISSION" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<receiver android:name="com.fortumo.android.BillingSMSReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<service android:name="com.fortumo.android.FortumoService" />
<service android:name="com.fortumo.android.StatusUpdateService" />
<activity
android:name="com.fortumo.android.FortumoActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<receiver
android:name=".PaymentStatusReceiver"
android:permission="com.your.raha.PAYMENT_BROADCAST_PERMISSION" >
<intent-filter>
<action android:name="com.fortumo.android.PAYMENT_STATUS_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name="com.fortumo.android.FortumoActivity"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".PaymentStatusReceiver"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.uugudev.rahaboss.PAYMENTSTATUSRECEIVER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name="com.fortumo.android.FortumoActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<service android:name="com.fortumo.android.FortumoService" />
<activity
android:name=".Soundboard"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".FortumoMaksa"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.uugudev.rahaboss.FORTUMOMAKSA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
So basically I'm trying to start the Soundboard.Osteti(); in the Soundboard.java that adds 32000 to the counter int and then updates the TextView. But nothing happens.
Hope somebody can help me. Thanks!
I'm still trying to make this work.
There is this thing I think you've wrong in your manifest:
PaymentStatusReceiver it's not an activity, and you only need to configure that as a receveiver (as you already had).
Related
I have problems with buttons.I have made 2 buttons that will when pressed open other activity(class).In code there is no error but when I launch emulator it just doesn't work and isn't opening those classes.
My button's btnopis and btnpronadi don't work(they are not opening other activity(class)).But I have button exit that Works and closes app. I don't get where the problem is. Here is the code
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
izlaz();
}
public Button btnopis;
public void otvoriopis(){
btnopis=(Button)findViewById(R.id.btnopis);
btnopis.setOnClickListener(new Button.OnClickListener() {
#Override
public void onClick(View v) {
Intent otvoriopis= new Intent(MainActivity.this,Opis.class);
startActivity(otvoriopis);
}
});
}
public Button btnpronadi;
public void otvoripronadi(){
btnpronadi=(Button)findViewById(R.id.btnpronadi);
btnpronadi.setOnClickListener(new Button.OnClickListener() {
#Override
public void onClick(View v) {
Intent otvoripronadi= new Intent(MainActivity.this,Pronadi.class);
startActivity(otvoripronadi);
}
});
}
public Button btnizlaz;
public void izlaz(){
btnizlaz=(Button)findViewById(R.id.btnizlaz);
btnizlaz.setOnClickListener(new Button.OnClickListener() {
#Override
public void onClick(View v) {
finish();
System.exit(0);
}
});
}
}
here is the manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shromid">
<application
android:allowBackup="true"
android:icon="#mipmap/app_ikona"
android:roundIcon="#mipmap/app_icon_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashScreen"
android:label="ShromID"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
<activity android:name=".Opis" />
<activity android:name=".Pronadi"></activity>
</application>
</manifest>
You forgot do call otvoriopis() and otvoripronadi() at onCreate:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
izlaz();
otvoriopis();
otvoripronadi();
}
You should call your functions in onCreate method, like you did for 'izlaz'
I have created watchface for android wear and my code is as follows:
ComapnionConfigActivity (in mobile module):
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.wearable.Wearable;
public class CompanionConfigActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_companion_config);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
#Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
#Override
protected void onStop() {
mGoogleApiClient.disconnect();
super.onStop();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_watch_config, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onConnected(Bundle bundle) {
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
}
Manifest for mobile module:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.agile.mywatchface" >
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="#drawable/square"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".CompanionConfigActivity"
android:label="#string/title_activity_watch_config" >
<intent-filter>
<action android:name="com.example.agile.mywatchface.MAIN" />
<category android:name= "com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
MyWatchfaceService: (service in wear module for drawing watchface)
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.wearable.watchface.CanvasWatchFaceService;
import android.view.SurfaceHolder;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
/**
*
* Created by agile on 3/5/2015.
*/
public class MyWatchfaceService extends CanvasWatchFaceService{
Calendar c;
int hrs,min,sec,width,height;
Timer timer;
TimerTask timerTask;
Paint paint;
#Override
public Engine onCreateEngine() {
return new MyEngine();
}
class MyEngine extends CanvasWatchFaceService.Engine {
#Override
public void onCreate(SurfaceHolder holder) {
super.onCreate(holder);
timer = new Timer();
timerTask = new MyTimerTask();
c = Calendar.getInstance();
paint = new Paint();
paint.setColor(Color.BLUE);
paint.setTextSize(18);
}
#Override
public void onPropertiesChanged(Bundle properties) {
super.onPropertiesChanged(properties);
}
#Override
public void onTimeTick() {
super.onTimeTick();
}
#Override
public void onDraw(Canvas canvas, Rect bounds) {
updateTimeOnEachSecond();
width = bounds.width();
height = bounds.height();
canvas.drawText(String.valueOf(hrs)+":"+String.valueOf(min)+":"+String.valueOf(sec),width/2,height/2,paint);
}
#Override
public void onVisibilityChanged(boolean visible) {
super.onVisibilityChanged(visible);
}
}
public void updateTimeOnEachSecond() {
timer.scheduleAtFixedRate(timerTask, 0, 1000);
}
class MyTimerTask extends TimerTask {
public void run(){
hrs = c.get(Calendar.HOUR_OF_DAY);
min = c.get(Calendar.MINUTE);
sec = c.get(Calendar.SECOND);
}
}
}
Manifest for wear module:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.agile.mywatchface" >
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="#drawable/square"
android:label="#string/app_name"
>
<service
android:name=".MyWatchfaceService"
android:label="#string/app_name"
android:permission="android.permission.BIND_WALLPAPER"
android:allowEmbedded="true"
>
<!-- companion configuration activity -->
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/watch_face" />
<meta-data
android:name="com.example.agile.mywatchface.preview"
android:resource="#drawable/square" />
<meta-data
android:name="com.example.agile.mywatchface.preview_circular"
android:resource="#drawable/square" />
<meta-data
android:name="com.google.android.wearable.watchface.companionConfigurationAction"
android:value="com.example.agile.mywatchface.MAIN" />
<!-- wearable configuration activity -->
<meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="com.example.agile.mywatchface.MAIN" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.example.agile.mywatchface.category.WATCH_FACE" />
</intent-filter>
</service>
<activity
android:name=".WearConfigActivity"
android:label="#string/title_activity_wear_config"
android:allowEmbedded="true">
<intent-filter>
<action android:name="com.example.agile.mywatchface.CONFIG_DIGITAL" />
<category android:name=
"com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="com.example.agile.mywatchface.MAIN" />
</activity>
</application>
</manifest>
I have followed official guide for creating watchface. But, when I install the app, it isn't showing in companion app. It seems like the problem is in manifest or companionconfigactivity. I tried for more than a day but couldn't identify it. Can anyone help me out?
In your Wearable Manifest you have following line:
<category android:name="com.example.agile.mywatchface.category.WATCH_FACE" />
This is incorrect, you need to use
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
Android Wear looks for services with this category in the filter, it will ignore yours if you use custom category.
I wrote that code to send data to parse.com then to receive it also but I can't even send it till now, why ?!! I don't know the main reason, I put the internet and network permission in AndroidManifest.xml the parse class in application also in AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mkadaimtwo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="com.example.mkadaimtwo.ParseCode"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
and also put the parse class in application also in AndroidManifest.xml and that two codes of class and main Activity
ParseCode class Activity :
package com.example.mkadaimtwo;
import com.parse.Parse;
import android.app.Application;
public class ParseCode extends Application {
public void onCreate() {
Parse.initialize(this, "GIuhlGILKRd8itvCF79femTyReHM6XjVkrfLKm3X", "Fjg4tBrMgl0mY47K4kCL7hVmXhu8FmkE2on9PlXK");
}
}
the MainActivity Code :
package com.example.mkadaimtwo;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.net.ParseException;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.EditText;
import com.parse.GetCallback;
import com.parse.ParseObject;
import com.parse.ParseQuery;
public class MainActivity extends ActionBarActivity {
EditText etCompanyName,etAddress,etNumberOfEmployees,etContactNumber;
ProgressDialog pd,pd2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etCompanyName = (EditText) findViewById(R.id.etCompanyName);
etAddress = (EditText) findViewById(R.id.etAddress);
etNumberOfEmployees = (EditText) findViewById(R.id.etNumberOfEmployees);
etContactNumber = (EditText) findViewById(R.id.etContactNumber);
pd = new ProgressDialog(this);
pd.setTitle("wait");
pd.setMessage("by7aml elmafrod");
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setCancelable(true);
pd2 = new ProgressDialog(this);
pd2.setTitle("wait");
pd2.setMessage("by7aml elmafrod");
pd2.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd2.setCancelable(true);
//here we will Load the old company data from Parse.com
ParseQuery<ParseObject> query = ParseQuery.getQuery("TestBosyApp");
query.getInBackground("ijy1qi78g8", new GetCallback<ParseObject>() {
public void done(ParseObject testBosyApp, ParseException e) {
if (e == null) {
String companyName = testBosyApp.getString("company_name");
String address = testBosyApp.getString("address");
String numberOfEmployees = testBosyApp.getString("number_of_employees");
String contactNumber = testBosyApp.getString("contact_number");
etCompanyName.setText(companyName);
etAddress.setText(address);
etNumberOfEmployees.setText(numberOfEmployees);
etContactNumber.setText(contactNumber);
pd.dismiss();
} else {
AlertDialog.Builder mDialoge = new AlertDialog.Builder(MainActivity.this);
mDialoge.setTitle("Erorr");
mDialoge.setMessage("Check el net plz :)");
mDialoge.setPositiveButton("ok", null);
mDialoge.show();
}
}
#Override
public void done(ParseObject arg0, com.parse.ParseException arg1) {
// TODO Auto-generated method stub
}
});
}
public void update (View V){
pd2.show();
//update data in Parse
ParseQuery<ParseObject> myQuery = ParseQuery.getQuery("TestBosyApp");
// Retrieve the object by id
myQuery.getInBackground("U6Gwn2tiD8", new GetCallback<ParseObject>() {
public void done(ParseObject testBosyApp, ParseException e) {
if (e == null) {
//Initials our variables
String companyName = etCompanyName.getText().toString().trim();
String address = etAddress.getText().toString().trim();
String numberOfEmployees = etNumberOfEmployees.getText().toString().trim();
String contactNumber = etContactNumber.getText().toString().trim();
//update it with new data
testBosyApp.put("company_name", companyName);
testBosyApp.put("address", address);
testBosyApp.put("number_of_employees", numberOfEmployees);
testBosyApp.put("contact_number", contactNumber);
testBosyApp.saveInBackground();
pd2.dismiss();
AlertDialog.Builder mDialoge = new AlertDialog.Builder(MainActivity.this);
mDialoge.setTitle("2shta");
mDialoge.setMessage("Keda eldata ra7t t2riban");
mDialoge.setPositiveButton("cool", null);
mDialoge.show();
}else{
pd2.dismiss();
AlertDialog.Builder mDialoge = new AlertDialog.Builder(MainActivity.this);
mDialoge.setTitle("Erorr");
mDialoge.setMessage("Check el net plz :)");
mDialoge.setPositiveButton("ok", null);
mDialoge.show();
}
}
#Override
public void done(ParseObject arg0, com.parse.ParseException arg1) {
// TODO Auto-generated method stub
}
});
}
}
so what's the problem, progress-bar is loading without end and if I give progress-bar cancellation feature then put data in fields there's nothing happen .
plus if anyone have tutorials for use android with parse.com please provide me with it.
Dude.. Sir? goto parse.com, there are tutorials.. you need to enable something i just do not remember Go to settings ->App Permissions ->Allow client class creation. Set it to ON> before you can send push from device and receive it.. also your manifest is not complete.. from what i know..
<application
android:name="com.example.mkadaimtwo.ParseCode"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//edit started here
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
so copy and paste this manifest
Probably it is just a silly mistake but i am having a Instantiate activity message when i tried to run my second activity
My first activity :
package com.burak.algonder;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
#Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b= (Button) findViewById(R.id.but2);
b.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast toast = Toast.makeText(getBaseContext(), "opucuk!", Toast.LENGTH_LONG);
toast.show();
startActivity(new Intent(MainActivity.this, Pozsyon.class));
}
});
}
}
My second Activity:
package com.burak.algonder;
import java.util.List;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.IBinder;
public class Pozsyon extends Service implements LocationListener {
private double[] getGPS() {
LocationManager lm = (LocationManager) getSystemService(
Context.LOCATION_SERVICE);
List<String> providers = lm.getProviders(true);
Location l = null;
for (int i=providers.size()-1; i>=0; i--) {
l = lm.getLastKnownLocation(providers.get(i));
if (l != null) break;
}
double[] gps = new double[2];
if (l != null) {
gps[0] = l.getLatitude();
gps[1] = l.getLongitude();
}
return gps;
}
#Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
#Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}
My Android Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.burak.algonder"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.burak.algonder.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.burak.algonder.Pozsyon" >
<intent-filter>
<action android:name="android.intent.action.Pozsyon" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="com.burak.algonder.SmsReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
Thank you for your help.
Pozsyon Class is not Activity and can't be started here!
i am unable to get the the front facing camera (camera id 1). open cam #1 failed appears on screen when i try to run the following code.
enclosed a snippet. any help will be appreciated (i am trying it on nexus 4).
Tester.java
package com.example.cam;
import java.util.HashMap;
import java.util.Iterator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Toast;
public class Tester extends Activity {
private static final int[] camIds = { Camera.CameraInfo.CAMERA_FACING_BACK, Camera.CameraInfo.CAMERA_FACING_FRONT };
#SuppressLint("UseSparseArrays")
private final HashMap<Integer, Camera> camMap = new HashMap<Integer, Camera>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
#Override
protected void onResume() {
super.onResume();
if (!checkCameraHardware())
finish();
getCameras();
releaseCamera();
}
#Override
protected void onPause() {
super.onPause();
releaseCamera();
}
#Override
protected void onStop() {
super.onStop();
releaseCamera();
}
#Override
protected void onDestroy() {
super.onDestroy();
releaseCamera();
}
private final void doToast(final String message) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
private final void getCameras() {
for (int camId : camIds)
try {
camMap.put(camId, Camera.open(camId));
doToast("open cam #" + camId + " succeeded");
} catch (Exception e) {
doToast("open cam #" + camId + " failed");
}
}
private final void releaseCamera() {
final Iterator<Integer> iter = camMap.keySet().iterator();
while (iter.hasNext())
camMap.remove(iter.next()).release();
}
private final boolean checkCameraHardware() {
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA))
return camIds.length <= Camera.getNumberOfCameras();
else
return false;
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cam"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
<uses-permission android:name="android.permission.CAPTURE_SECURE_VIDEO_OUTPUT" />
<uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.cam.Tester"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>