gpt4 book ai didi

android - 如何在Android中初始化parse.com代码

转载 作者:搜寻专家 更新时间:2023-11-01 08:00:53 25 4
gpt4 key购买 nike

我正在尝试使用 Parse.com sdk,但无法让我的 Parse 代码进行初始化。我不知道把它放在哪里,我需要帮助,因为我不知道我是否需要把它放在我的主目录中,或者我是否需要把它放在其他地方。

这是我放在不同类中的几段代码

我用示例创建了这个

package com.example.musicdroid;
import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseUser;
import android.app.Application;

public class ParseApplication extends Application {

@Override
public void onCreate() {
super.onCreate();

// Add your initialization code here
Parse.initialize(this, "XXX", "XXX");

ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();


ParseACL.setDefaultACL(defaultACL, true);
}

这是我最初拥有它的地方

import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseInstallation;
import com.parse.PushService;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Main extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] choices = { "Rock", "Metal", "Rap", "My Favorites" };
setListAdapter(new ArrayAdapter<String>(this, R.layout.main,
R.id.music, choices));
}

protected void onListItemClick(ListView l, View v, int position, long id) {
switch (position) {
case 0:
try {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("spotify:user:warnermusicus:playlist:3DRD3GUpQSjK2rryIRVOPS")));
} catch (ActivityNotFoundException e) {
final Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=com.spotify.mobile.android.ui"));
startActivity(intent);
}
break;
case 1:
try {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("spotify:user:warnermusicus:playlist:6iIDHF5tBqzS6uZjMEzBdQ")));
} catch (ActivityNotFoundException e) {
final Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=com.spotify.mobile.android.ui"));
startActivity(intent);
}
break;
case 2:
try {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("spotify:user:digsterdeutschland:playlist:5pvJLjAhcKCHXGOb7pEbBZ")));
} catch (ActivityNotFoundException e) {
final Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=com.spotify.mobile.android.ui"));
startActivity(intent);
}
break;
case 3:
try {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("spotify:user:digsterdeutschland:playlist:1hYWCuFv5Eav9yIZXHwnpd")));
} catch (ActivityNotFoundException e) {
final Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=com.spotify.mobile.android.ui"));
startActivity(intent);
}
break;
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

我有它的另一个地方。这是主菜单

package com.example.musicdroid;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainMenu extends ListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] choices = { "Main", "Bios", "Artist Search", "How To Use" };
setListAdapter(new ArrayAdapter<String>(this, R.layout.menu, R.id.Menu,
choices));
}

protected void onListItemClick(ListView l, View v, int position, long id) {
switch (position) {
case 0:
startActivity(new Intent(MainMenu.this, Main.class));
break;
case 1:
startActivity(new Intent(MainMenu.this, Bios.class));
break;
case 2:
startActivity(new Intent(MainMenu.this, Search.class));
break;
case 3:
startActivity(new Intent(MainMenu.this, How.class));
break;
}
}
}

list 代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.musicdroid"
android:versionCode="1"
android:versionName="1.0" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<permission
android:name="com.example.musicdroid.permission.C2D_MESSAGE"
android:protectionLevel="signature" />

<uses-permission android:name="com.example.musicdroid.permission.C2D_MESSAGE" />

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/fiery_music_symbol"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
<activity
android:name="com.example.musicdroid.Main"
android:label="@string/app_name" >
</activity>
<activity android:name=".MainMenu" >
</activity>
<activity android:name=".Bios" >
</activity>
<activity android:name=".Search" >
</activity>
<activity android:name=".How" >
</activity>
<activity android:name=".LoginSignupActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Welcome" >
</activity>

<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>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.musicdroid" />
</intent-filter>
</receiver>
</application>

</manifest>

最佳答案

在 list 文件中添加扩展应用程序的类

<application android:name="your packagename.ParseApplication" 

android:icon="@drawable/icon"

android:label="@string/app_name">

希望对你有帮助

关于android - 如何在Android中初始化parse.com代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21410439/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com