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
Related
I'm developing this android application, that receives data from the gallery (in my case an image) and displays it. What i also had to do is to create a SplashScreen for my app. But when i did my intent became null .
Manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.xkbc1923.myapplication">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AlertExampleActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
</application>
SplashScreen
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreen extends Activity {
private static final int DISPLAY_DURATION = 1000;
#Override
protected final void onCreate(final Bundle savedInstState) {
super.onCreate(savedInstState);
setContentView(R.layout.activity_splashscreen);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(SplashScreen.this, AlertExampleActivity.class);
startActivity(i);
// close this activity
finish();
}
}, DISPLAY_DURATION);
}
}
MainActivity
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import static android.provider.CalendarContract.CalendarCache.URI;
public class AlertExampleActivity extends AppCompatActivity {
ImageView picView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
///get the image view
//get the text view
setContentView(R.layout.activity_alert_example);
picView = (ImageView) findViewById(R.id.picture);
TextView txtView = (TextView) findViewById(R.id.txt);
if (txtView ==null) {
Log.w("Example", "TextView is null");
}
//get the received intent
Intent receivedIntent = getIntent();
//get the action
String receivedAction = receivedIntent.getAction();
//find out what we are dealing with
String receivedType = receivedIntent.getType();
//make sure it's an action and type we can handle
if (receivedAction.equals(Intent.ACTION_SEND)) {
Log.d("Example", "Send received");
//content is being shared
if (receivedType.startsWith("text/")) {
Log.d("Example", "Text received");
//handle sent text
//hide the other ui item
picView.setVisibility(View.GONE);
//get the received text
String receivedText = receivedIntent.getStringExtra(Intent.EXTRA_TEXT);
//check we have a string
if (receivedText != null) {
//set the text
txtView.setText(receivedText);
}
} else if (receivedType.startsWith("image/")) {
Log.d("Example", "Image received");
//handle sent image
handleSendImage(receivedIntent);
}
} else if (receivedAction.equals(Intent.ACTION_MAIN)) {
//app has been launched directly, not from share list
Log.d("Example", "Direct launch of App");
}
}
private void handleSendImage(Intent intent) {
// Get the image URI from intent
Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
// When image URI is not null
if (imageUri != null) {
// Update UI to reflect image being shared
picView.setImageURI(imageUri);
} else{
Toast.makeText(this, "Error occured, URI is invalid", Toast.LENGTH_LONG).show();
}
}
}
You did not add any extra data to your intent. So it would be null normally. Just add necessary data to Intent (i) on SplashScreen.java. Ex -
i.setAction("action");
i.setType("type");
i.putExtra("key", "value");
I am not sure if this gonna solve your problem but you can try.
Instead of :
Intent i = new Intent(SplashScreen.this, AlertExampleActivity.class);
startActivity(i);
// close this activity
finish();
Try this:
startActivity(new Intent(SplashScreen.this, AlertExampleActivity.class));
finish();
I've changed the manifest file since i want the splashscreen to appear even when it's externally called .
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".AlertExampleActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
</application>
And changed the SplashscreenActivity :
public class SplashScreen extends Activity {
private static final int DISPLAY_DURATION = 1000;
#Override
protected final void onCreate(final Bundle savedInstState) {
super.onCreate(savedInstState);
setContentView(R.layout.activity_splashscreen);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(SplashScreen.this, AlertExampleActivity.class);
i.setAction(Intent.ACTION_SEND);
i.setType("*/*");
String[] mimetypes = {"image/*", "video/*"};
i.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
startActivity(i);
// close this activity
finish();
}
}, DISPLAY_DURATION);
}
}
I haven't changed anything in the MainActivity , but now i no longer receive the image ... I'm new to Android so i would really appreciate the explanation.
I have this sourcecode :
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.net.URL;
import facebook4j.Account;
import facebook4j.Facebook;
import facebook4j.FacebookFactory;
import facebook4j.PostUpdate;
import facebook4j.auth.AccessToken;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try{
Facebook facebook = new FacebookFactory().getInstance();
facebook.setOAuthAppId(String.valueOf(R.string.facebook_app_id), String.valueOf(R.string.facebook_app_secret));
facebook.setOAuthAccessToken(new facebook4j.auth.AccessToken("10000000000003|mqs000000000000C46A"));
String pageToken = "EAAUB000000000000000000000000000000000000000000000123000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AZDZD";
for (Account a : facebook.getAccounts()) {
if (a.getName().toLowerCase().contains("nameOfPage")) {
pageToken = a.getAccessToken();
PostUpdate post = new PostUpdate(new URL("https://facebook.com/1000000000000003/feed"))
.picture(new URL("http://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png"))
.name("example name")
.caption("example caption")
.message("example message")
.description("example description");
if (pageToken != null) {
facebook.setOAuthAccessToken(new AccessToken("EAAUB000000000000000000000000000000000000000000000000000123000000000000000000000000000000000000000000123000000000000000000000000000000000000000000000000000000000000000000000AZDZD"));
facebook.postFeed(post);
//ScriptGroup.Input.addInfoAnnotation(req, "sysAdminTools.annotation.fb.ok");
}
}
}
}catch(Exception e){
System.out.println();
}
}
}
With manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<provider android:authorities="com.facebook.app.FacebookContentProvider1400000000000003"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
and it is not working. I am trying to Google it for over a hour and I cant find anything expect this. I have PageToken, AppToken with AppSecret already generated by myself. Can you please explain me whats wrong and recommend sollution?
Every time I press button logcat shows this but nothing happen:
09-11 8:24:69.420 28087-28087/test.app I/HwSecImmHelper: mSecurityInputMethodService is null
App is not crashing, no errors are thrown, just nothing is happening at all.
Thanks
Sorry for my english. I have spent 2 days but I can't send push messages to android. I use google cloud message. For example in gcm I create a new project and I have an id:
Then I enabled gcm and added the server key
I have code like this:
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alexy.gcmclient">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.hmkcode.android.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.hmkcode.android.gcm.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/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>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.hmkcode.android.gcm" />
</intent-filter>
</receiver>
<service
android:name=".GcmMessageHandler"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
</application>
</manifest>
GcmBroadcastReceiver
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Log.e("GcmBroadcastReceiver", "GcmBroadcastReceiver");
// Explicitly specify that GcmMessageHandler will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GcmMessageHandler.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
GcmMessageHandler
public class GcmMessageHandler extends IntentService {
String mes;
private Handler handler;
public GcmMessageHandler() {
super("GcmMessageHandler");
}
#Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
handler = new Handler();
Log.e("GcmMessageHandler", "GcmMessageHandler");
}
#Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// The getMessageType() intent parameter must be the intent you received
// in your BroadcastReceiver.
String messageType = gcm.getMessageType(intent);
Log.e("message", messageType);
}
Main
public class MainActivity extends Activity implements OnClickListener{
Button btnRegId, unregister;
EditText etRegId;
GoogleCloudMessaging gcm;
String regid;
String PROJECT_NUMBER = "308****";
private BroadcastReceiver mRegistrationBroadcastReceiver;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
unregister = (Button) findViewById(R.id.unregister);
btnRegId = (Button) findViewById(R.id.btnGetRegId);
etRegId = (EditText) findViewById(R.id.etRegId);
btnRegId.setOnClickListener(this);
}
public void getRegId(){
new AsyncTask<Void, Void, String>() {
#Override
protected String doInBackground(Void... params) {
String msg = "";
try {
InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
String token = instanceID.getToken(PROJECT_NUMBER,
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
msg = token;
//apiKey = msg;
GcmPubSub.getInstance(getApplicationContext()).subscribe(token, "/topics/users", null);
} catch (IOException ex) {
msg = "Error :" + ex.getMessage();
}
return msg;
}
#Override
protected void onPostExecute(String msg) {
etRegId.setText(msg + "\n");
Log.e("key", msg);
}
}.execute(null, null, null);
}
#Override
public void onClick(View v) {
getRegId();
}
}
I use service and tried to send some push messages to the device. In service it says Success. But the push in android is not coming (I have no output in the log)
I assume your app package name must be com.example.alexy.gcmclient or replace the package name build.gradle
defaultConfig
applicationId "com.yourpackge"
<permission
android:name="com.example.alexy.gcmclient.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.example.alexy.gcmclient.permission.C2D_MESSAGE" />
<receiver android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.alexy.gcmclient" />
</intent-filter>
</receiver>
The package names for C2D_MESSAGE are wrong, change them to your package name. Also, make sure you have the configuration file near the build.gradle of your app directory. Edit: go through all of the manifest and change wherever you see hmk to your package name. Your package name should be com.example.alexy.gcmclient as per your manifest.
I know I already asked this, but I didn't get a sufficient answer. Im trying to start an activity, but the emulator stays on the first activity. Ive tried all ways to do it but it never works. The youtube videos show that it should work but it never does. Is there something missing or is there anything wrong with the following code?
//First Activity:
package com.mtprogramming.magicsquaresgame;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.content.Intent;
public class Opening extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opening);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}finally{
Intent open = new Intent("com.mtprogramming.magicsquaresgame.MENU");
startActivity(open);
}
}
};
timer.start();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.opening, menu);
return true;
}
}
//Second Activity:
package com.mtprogramming.magicsquaresgame;
import android.app.Activity;
import android.os.Bundle;
//Created by suprav on 7/11/13.
public class Menu extends Activity {
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
}
}
//Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mtprogramming.magicsquaresgame"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.mtprogramming.magicsquaresgame.Opening"
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.mtprogramming.magicsquaresgame.Menu"
android:label="#string/title_activity_menu"
android:parentActivityName="Opening" >
<intent-filter>
<action android:name="com.mtprogramming.magicsquaresgame.MENU"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="Opening" />
</activity>
</application>
</manifest>
Try this:
Intent open = new Intent(Opening.this, Menu.class);
startActivity(open);
I think i found the issue, seems like metadata property is not being properly used, hences activity its not being started, this is the proper way to use the property:
<activity android:name=".TestActivity" >
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value=".TestParentActivity">
</meta-data>
</activity>
So, seems like you are missing a dot in "android:value="Opening"
Regards!
The problem is that if i use these two lines of code,my app closes unxepectedly and if not used, the app works just fine...is there any other way to get to the maps.class?
The following is the code i used:
Intent in = new Intent(BlobCity.this, maps.class)
startActivity(in);
the following is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="BlobCity.xyz.com"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-library android:name="com.google.android.maps" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".BlobCity"
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=".maps" />
</application>
</manifest>
blobcity.java:
public class BlobCity extends Activity
{
/** Called when the activity is first created. */
Button signIn,register;
TextView Blob,City,username,password;
EditText eUsername,ePassword;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
signIn = (Button) findViewById(R.id.signIn);
register = (Button) findViewById(R.id.register);
Blob = (TextView) findViewById(R.id.blob);
City = (TextView) findViewById(R.id.city);
username = (TextView) findViewById(R.id.username);
password = (TextView) findViewById(R.id.password);
eUsername = (EditText) findViewById(R.id.eUsername);
ePassword = (EditText) findViewById(R.id.ePassword);
signIn.setOnClickListener(new sendUserPass());
register.setOnClickListener(new regPage());
}
class sendUserPass implements Button.OnClickListener
{
public void onClick(View v)
{
String uname = eUsername.getText().toString();
String pwd = ePassword.getText().toString();
String requestString = ("http://192.168.1.102:8080/BlobCity/RemoteLogin?email="+ uname + "&pwd=" + pwd);
String line;
try {
HttpResponse response = new DefaultHttpClient().execute(new HttpGet(requestString));
InputStream is = response.getEntity().getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuilder rb = new StringBuilder("");
while ((line=br.readLine()) != null)
{
rb.append(line) ;
}
if(rb.toString().equals("0"))
{
Toast toast = Toast.makeText(getApplicationContext(), "Please enter a valid Username and/or Password!", Toast.LENGTH_LONG);
toast.show();
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
eUsername.setText("");
ePassword.setText("");
}
else
{
Intent in = new Intent(BlobCity.this, maps.class);
startActivity(in);
eUsername.setText("");
ePassword.setText("");
}
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
class regPage implements Button.OnClickListener
{
public void onClick(View v)
{
Intent browse = new Intent( Intent.ACTION_VIEW , Uri.parse("http://www.blobcity.com") );
startActivity(browse);
}
}
}
maps.java:
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class maps extends MapActivity{
MapView mapView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapView = (MapView) findViewById(R.id.map);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Your tag <uses-library android:name="com.google.android.maps" /> has to be inside the <application> tag!
manifest has to be like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="BlobCity.xyz.com"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
**<uses-library android:name="com.google.android.maps" />**
<activity android:name=".BlobCity"
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=".maps" />
</application>
</manifest>
Try:
Intent in = new Intent(BlobCity.this.getApplicationContext(), maps.class)
startActivity(in);
Activity (Class) name must start with capital letter, and instead of using BlobCity.this use only "this" keyword which refers the Context of the current Activity
e.g.
Intent in = new Intent(this, Maps.class)
startActivity(in);
also make sure entry of this Activity must be in your AndroidManifest.xml file
e.g.
<activity android:name=".Maps"></activity>
also you can follow a great tutorial on Android Google Maps here :
http://mobiforge.com/developing/story/using-google-maps-android