1

1 が 1 つの jar API ファイルを追加しました。ここにサンプルコードの残りの部分があります

http://innovator.samsungmobile.com/cms/cnts/knowledge.detail.view.do?platformId=1&cntsId=9986&nacode=からダウンロードしました

エラーが発生しています:

06-01 18:22:31.900: E/AndroidRuntime(24713): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.samsungapps.plasma.plasmatester/com.samsungapps.plasma.plasmatester.PlasmaTesterActivity}: java.lang.ClassNotFoundException: com.samsungapps.plasma.plasmatester.PlasmaTesterActivity in loader dalvik.system.PathClassLoader[/data/app/com.samsungapps.plasma.plasmatester-1.apk]

    public class PlasmaTesterActivity extends Activity implements PlasmaListener {
    private class ItemInformationListAdapter extends
            ArrayAdapter<ItemInformation> {

        public ItemInformationListAdapter(Context context,
                int textViewResourceId, ArrayList<ItemInformation> objects) {
            super(context, textViewResourceId, objects);

            __itemInformationList = objects;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                LayoutInflater inflater = PlasmaTesterActivity.this
                        .getLayoutInflater();
                v = inflater.inflate(R.layout.row, null);
            }

            final ItemInformation pi = __itemInformationList.get(position);
            if (pi != null) {
                TextView tv1 = (TextView) v.findViewById(R.id.textView1);
                tv1.setText(pi.getItemName());
                TextView tv2 = (TextView) v.findViewById(R.id.textView2);
                tv2.setText(getPriceStringWithCurrencyUnit(pi));
                TextView tv3 = (TextView) v.findViewById(R.id.textView3);
                tv3.setText(pi.getItemDescription());
                Button b = (Button) v.findViewById(R.id.button1);
                b.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        __plasma.requestPurchaseItem(__transactionId++,
                                pi.getItemId());
                    }
                });
            }

            return v;
        }

        private ArrayList<ItemInformation> __itemInformationList = null;
    }

    private class PurchasedItemInformationListAdapter extends
            ArrayAdapter<PurchasedItemInformation> {

        public PurchasedItemInformationListAdapter(Context context,
                int textViewResourceId,
                ArrayList<PurchasedItemInformation> objects) {
            super(context, textViewResourceId, objects);

            __purchasedItemInformationList = objects;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                LayoutInflater inflater = PlasmaTesterActivity.this
                        .getLayoutInflater();
                v = inflater.inflate(R.layout.row, null);
            }

            final PurchasedItemInformation pi = __purchasedItemInformationList
                    .get(position);
            if (pi != null) {
                TextView tv1 = (TextView) v.findViewById(R.id.textView1);
                tv1.setText(pi.getItemName());
                TextView tv2 = (TextView) v.findViewById(R.id.textView2);
                tv2.setText(getPriceStringWithCurrencyUnit(pi));
                TextView tv3 = (TextView) v.findViewById(R.id.textView3);
                tv3.setText(pi.getPaymentId());

                Button b = (Button) v.findViewById(R.id.button1);
                b.setVisibility(View.GONE);
            }

            return v;
        }

        private ArrayList<PurchasedItemInformation> __purchasedItemInformationList = null;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        __plasma = new Plasma(__ITEM_GROUP_ID, this);
        __plasma.setPlasmaListener(this);
        __plasma.setDeveloperFlag(1);

        ArrayList<ItemInformation> itemInformationList = new ArrayList<ItemInformation>();
        __itemInformationListAdapter = new ItemInformationListAdapter(this,
                R.layout.row, itemInformationList);

        ArrayList<PurchasedItemInformation> purchasedItemInformationList = new ArrayList<PurchasedItemInformation>();
        __purchasedItemInformationListAdapter = new PurchasedItemInformationListAdapter(
                this, R.layout.row, purchasedItemInformationList);

        ListView itemList = (ListView) findViewById(R.id.listView1);
        itemList.setAdapter(__itemInformationListAdapter);

        ListView purchaseList = (ListView) findViewById(R.id.listView2);
        purchaseList.setAdapter(__purchasedItemInformationListAdapter);

        Button getItemListButton = (Button) findViewById(R.id.button1);
        getItemListButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                __plasma.requestItemInformationList(__transactionId++, 1,
                        __ITEM_LIST_REQUEST_COUNT);
            }
        });

        Button getPurchaseListButton = (Button) findViewById(R.id.button2);
        getPurchaseListButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                __plasma.requestPurchasedItemInformationList(__transactionId++,
                        1, __ITEM_LIST_REQUEST_COUNT);
            }
        });
    }

    @Override
    public void onItemInformationListReceived(int transactionId,
            int statusCode, ArrayList<ItemInformation> itemInformationList) {
        switch (statusCode) {
        case Plasma.STATUS_CODE_SUCCESS:
            __itemInformationListAdapter.clear();
            for (int i = 0; i < itemInformationList.size(); i++) {
                ItemInformation itemInformation = itemInformationList.get(i);
                __itemInformationListAdapter.add(itemInformation);
            }
            __itemInformationListAdapter.notifyDataSetChanged();
            break;
        default:
            String errorMessage = "Failed to retrieve the item list";
            showErrorDialog(statusCode, errorMessage);
            break;
        }
    }

    @Override
    public void onPurchasedItemInformationListReceived(int transactionId,
            int statusCode,
            ArrayList<PurchasedItemInformation> purchasedItemInformationList) {
        switch (statusCode) {
        case Plasma.STATUS_CODE_SUCCESS:
            __purchasedItemInformationListAdapter.clear();
            for (int i = 0; i < purchasedItemInformationList.size(); i++) {
                PurchasedItemInformation purchasedItemInformation = purchasedItemInformationList
                        .get(i);
                __purchasedItemInformationListAdapter
                        .add(purchasedItemInformation);
            }
            __purchasedItemInformationListAdapter.notifyDataSetChanged();
            break;
        default:
            String errorMessage = "Failed to retrieve the purchase list";
            showErrorDialog(statusCode, errorMessage);
            break;
        }
    }

    @Override
    public void onPurchaseItemFinished(int transactionId, int statusCode,
            PurchasedItemInformation purchasedItemInformation) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);

        switch (statusCode) {
        case Plasma.STATUS_CODE_SUCCESS:
            StringBuilder purchasedItemInformationStringBuilder = new StringBuilder();
            purchasedItemInformationStringBuilder.append("Item name: ");
            purchasedItemInformationStringBuilder
                    .append(purchasedItemInformation.getItemName());
            purchasedItemInformationStringBuilder.append(__CR_LF);
            purchasedItemInformationStringBuilder.append("Item ID: ");
            purchasedItemInformationStringBuilder
                    .append(purchasedItemInformation.getItemId());
            purchasedItemInformationStringBuilder.append(__CR_LF);
            purchasedItemInformationStringBuilder.append("Payment ID: ");
            purchasedItemInformationStringBuilder
                    .append(purchasedItemInformation.getPaymentId());
            purchasedItemInformationStringBuilder.append(__CR_LF);
            purchasedItemInformationStringBuilder.append("Purchase date: ");
            purchasedItemInformationStringBuilder
                    .append(purchasedItemInformation.getPurchaseDate());

            purchasedItemInformationStringBuilder.append(__CR_LF);
            purchasedItemInformationStringBuilder.append("Price: ");
            purchasedItemInformationStringBuilder
                    .append(getPriceStringWithCurrencyUnit(purchasedItemInformation));

            alertDialogBuilder.setTitle("Purchase information");
            alertDialogBuilder.setMessage(purchasedItemInformationStringBuilder
                    .toString());
            alertDialogBuilder.show();
            break;
        case Plasma.STATUS_CODE_CANCEL:
            break;
        default:
            String errorMessage = "Failed to purchase the item";
            showErrorDialog(statusCode, errorMessage);
            break;
        }
    }

    private void showErrorDialog(int errorCode, String errorMessage) {
        String errorMessageWithCode = String.format("%s (%d)", errorMessage,
                errorCode);

        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setTitle("Error");
        alertDialogBuilder.setMessage(errorMessageWithCode);
        alertDialogBuilder.show();
    }

    private String getPriceStringWithCurrencyUnit(
            ItemInformation itemInformation) {
        String priceStringFormatString = null;
        if (itemInformation.getCurrencyUnitHasPenny()) {
            priceStringFormatString = "%.2f";
        } else {
            priceStringFormatString = "%.0f";
        }

        String priceString = String.format(priceStringFormatString,
                itemInformation.getItemPrice());

        StringBuffer priceStringWithCurrencyUnitBuffer = new StringBuffer();
        if (itemInformation.getCurrencyUnitPrecedes()) {
            priceStringWithCurrencyUnitBuffer.append(itemInformation
                    .getCurrencyUnit());
            priceStringWithCurrencyUnitBuffer.append(priceString);
        } else {
            priceStringWithCurrencyUnitBuffer.append(priceString);
            priceStringWithCurrencyUnitBuffer.append(itemInformation
                    .getCurrencyUnit());
        }

        return priceStringWithCurrencyUnitBuffer.toString();
    }

    private ItemInformationListAdapter __itemInformationListAdapter = null;
    private PurchasedItemInformationListAdapter __purchasedItemInformationListAdapter = null;
    private int __transactionId = 0;
    private Plasma __plasma = null;

    private static final String __ITEM_GROUP_ID = "100000008752";
    private static final int __ITEM_LIST_REQUEST_COUNT = 15;
    private static final String __CR_LF = "\n";
}

およびマニフェスト ファイル

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.samsungapps.plasma.plasmatester" android:versionCode="1"
    android:versionName="1.5">
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".PlasmaTesterActivity" android:label="@string/app_name"
            android:configChanges="orientation|keyboardHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>
4

1 に答える 1

1

jarをlibsフォルダに入れましたか?(あなたはそれを追加したと言ったが、どこ/どのようにではなかった).

彼らは最近要件を変更したため、libs上記のフォルダーに移動する必要があります。

于 2012-06-01T13:42:40.623 に答える