badname
چهارشنبه 31 اردیبهشت 1393, 13:47 عصر
سلام خسته نباشد من با برنامه ام یه مشکل داشتم گفتم اینجا مطرح کنم شاید دوستان کمک کنن مشکل برنامه ما حل شه
برنامه مو رو چند تا گوشی تست کردم به خوبی جواب داد و کار کرد (Xperia mini pro (4.4.2) , Xperia T, Galaxy S3)
رو چند تا گوشی ام تست کردم جواب نداد همون اول Force Stop میده (Xperia miro, Galaxy Gio)
قبلا یه همچین مشکلی پیش اومده بود رو (4.1 )Xperia ion تست میکردم force stop میداد ولی حلش کردم.... (یادم رفته بود فایلامو تو پوشه HDPI بریزم :اشتباه:)
ولی الان چک کردم اونا درسته ظاهرا
اما فورس استاپ تو همون لحظه باز کردن برنامه تو (Xperia miro, Galaxy Gio) دارم...
کسی میتونه راهنمایی کنه ؟:ناراحت:
اینم کدام
از پرداخت دورن برنامه ای حامد جان ام استفاده کردم ... با تشکر از hamedjj
Main Activity:
public class MainActivity extends Activity {
Button imgqabout;
Button imgq1;
Button imgq2;
Button imgq3;
Button imgq4;
Button imgexit;
public ProgressDialog dialog;
private String PACKAGENAME = "" ;
final String KEY = "PERIMIUM" ;
SharedPreferences preferences = null ;
// Debug tag, for logging
static final String TAG = "";
// SKUs for our products: the premium upgrade (non-consumable)
static final String SKU_PREMIUM = "t";
// Does the user have the premium upgrade?
boolean mIsPremium = false;
// (arbitrary) request code for the purchase flow
static final int RC_REQUEST = 10001;
// The helper object
IabHelper mHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgqabout=(Button)findViewById(R.id.imgqabout);
imgq1=(Button)findViewById(R.id.imgq1);
imgq2=(Button)findViewById(R.id.imgq2);
imgq3=(Button)findViewById(R.id.imgq3);
imgq4=(Button)findViewById(R.id.imgq4);
imgexit=(Button)findViewById(R.id.imgexit);
imgq2.setEnabled(false);
imgq3.setEnabled(false);
imgq4.setEnabled(false);
imgq1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q1.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgq2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q2.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgq3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q3.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgq4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q4.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgexit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
overridePendingTransition(0, R.anim.end_in);
}
});
// load your setting that are you premium or not?
preferences = getSharedPreferences(PACKAGENAME,Context.MODE_PRIV ATE);
PACKAGENAME = getClass().getName();
Log.e("TAG", PACKAGENAME);
mIsPremium = preferences.getBoolean(KEY, false);
if (mIsPremium == true) {
updateUi();
return;
}
// show loading dialog with ProgressDialog
dialog = new ProgressDialog(this);
dialog.setMessage("loading...");
dialog.setCancelable(false);
dialog.setInverseBackgroundForced(false);
dialog.show();
String base64EncodedPublicKey = "MIHNMA0GCSqGSIbxxxEBAQUAA4G7ADCBtwKBrwDGhl8/QU3vPjgmTutAbItCBpdwwgFWSAFvzM/OOXVSMHaeH9fjRIxa3aLXVAfuoRJ3Q1ynbQL1Dc2hAvlTAgEeR FNmVkkjypzhZxK3O18wIYJiNleLd/pwwwwaoHeQB6s3eH3KB8uDn2TdZoYzmXxZkvMoDW2db3mT1NmP xJYm+xF7AN/p/Sr9YqEXpIpzsXbe6T30seUHmPDdM4r7h/r6hx/R/2hHvR/vnN0i6w8CAwEAAQ==";
// You can find it in your Bazaar console, in the Dealers section.
// It is recommended to add more security than just pasting it in your source code;
mHelper = new IabHelper(this, base64EncodedPublicKey);
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
// Hooray, IAB is fully set up!
mHelper.queryInventoryAsync(mGotInventoryListener) ;
}
});
}
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
if (result.isFailure()) {
Log.d(TAG, "Failed to query inventory: " + result);
dialog.hide();
return;
}
else {
Log.d(TAG, "Query inventory was successful.");
// does the user have the premium upgrade?
mIsPremium = inventory.hasPurchase(SKU_PREMIUM);
// update UI accordingly
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
}
dialog.hide();
updateUi();
setWaitScreen(false);
Toast.makeText(getApplicationContext(), mIsPremium? R.string.premium : R.string.notpremium, Toast.LENGTH_SHORT).show();
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};
public void onSavedUpgradeAppButtonClicked(View arg0) {
Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
setWaitScreen(true);
/* TODO: for security, generate your payload here for verification. See the comments on
* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
String payload = "gdhassdflsldaslfkahsjahsjakaasa";
mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, payload);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
} else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();
return true;
}
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
setWaitScreen(false);
return;
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
setWaitScreen(false);
return;
}
Log.d(TAG, "Purchase successful.");
if (purchase.getSku().equals(SKU_PREMIUM)) {
Log.d(TAG, "Purchase is premium upgrade. Congratulating user.");
alert("Thank you for upgrading to premium!");
mIsPremium = true;
updateUi();
setWaitScreen(false);
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "Destroying helper.");
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
// Update button with updateUi
public void updateUi() {
if (mIsPremium) {
imgq2=(Button)findViewById(R.id.imgq2);
imgq3=(Button)findViewById(R.id.imgq3);
imgq4=(Button)findViewById(R.id.imgq4);
imgqabout=(Button)findViewById(R.id.imgqabout);
imgq2.setEnabled(true);
imgq3.setEnabled(true);
imgq4.setEnabled(true);
imgqabout.setEnabled(false);
findViewById(R.id.imgq2).setBackgroundResource(R.d rawable.b);
findViewById(R.id.imgq3).setBackgroundResource(R.d rawable.c);
findViewById(R.id.imgq4).setBackgroundResource(R.d rawable.d);
findViewById(R.id.imgqabout).setBackgroundResource (R.drawable.u);
// change the mIsPremium to true
SharedPreferences.Editor newtask = preferences.edit();
newtask.putBoolean(KEY, true);
newtask.commit();
}
}
// Enables or disables the "please wait" screen.
void setWaitScreen(boolean set) {
findViewById(R.id.screen_wait).setVisibility(set ? View.VISIBLE : View.GONE);
}
void complain(String message) {
Log.e(TAG, "**** testbilling Error: " + message);
alert("Error: " + message);
}
void alert(String message) {
AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setMessage(message);
bld.setNeutralButton("OK", null);
Log.d(TAG, "Showing alert dialog: " + message);
bld.create().show();
}
}
Mainfest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.saeed.t"
android:versionCode="8"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR"></uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.saeed.t.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=".Q1"
android:screenOrientation="portrait"
android:noHistory="true"
>
</activity>
<activity
android:name=".Q2"
android:screenOrientation="portrait"
android:noHistory="true"
>
</activity>
<activity
android:name=".Q3"
android:screenOrientation="portrait"
android:noHistory="true"
>
</activity>
<activity
android:name=".Q4"
android:screenOrientation="portrait"
android:noHistory="true">
</activity>
</application>
</manifest>
برنامه مو رو چند تا گوشی تست کردم به خوبی جواب داد و کار کرد (Xperia mini pro (4.4.2) , Xperia T, Galaxy S3)
رو چند تا گوشی ام تست کردم جواب نداد همون اول Force Stop میده (Xperia miro, Galaxy Gio)
قبلا یه همچین مشکلی پیش اومده بود رو (4.1 )Xperia ion تست میکردم force stop میداد ولی حلش کردم.... (یادم رفته بود فایلامو تو پوشه HDPI بریزم :اشتباه:)
ولی الان چک کردم اونا درسته ظاهرا
اما فورس استاپ تو همون لحظه باز کردن برنامه تو (Xperia miro, Galaxy Gio) دارم...
کسی میتونه راهنمایی کنه ؟:ناراحت:
اینم کدام
از پرداخت دورن برنامه ای حامد جان ام استفاده کردم ... با تشکر از hamedjj
Main Activity:
public class MainActivity extends Activity {
Button imgqabout;
Button imgq1;
Button imgq2;
Button imgq3;
Button imgq4;
Button imgexit;
public ProgressDialog dialog;
private String PACKAGENAME = "" ;
final String KEY = "PERIMIUM" ;
SharedPreferences preferences = null ;
// Debug tag, for logging
static final String TAG = "";
// SKUs for our products: the premium upgrade (non-consumable)
static final String SKU_PREMIUM = "t";
// Does the user have the premium upgrade?
boolean mIsPremium = false;
// (arbitrary) request code for the purchase flow
static final int RC_REQUEST = 10001;
// The helper object
IabHelper mHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgqabout=(Button)findViewById(R.id.imgqabout);
imgq1=(Button)findViewById(R.id.imgq1);
imgq2=(Button)findViewById(R.id.imgq2);
imgq3=(Button)findViewById(R.id.imgq3);
imgq4=(Button)findViewById(R.id.imgq4);
imgexit=(Button)findViewById(R.id.imgexit);
imgq2.setEnabled(false);
imgq3.setEnabled(false);
imgq4.setEnabled(false);
imgq1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q1.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgq2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q2.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgq3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q3.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgq4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i= new Intent();
i.setClass(MainActivity.this,Q4.class);
startActivity(i);
finish();
overridePendingTransition( R.anim.pin, R.anim.pout );
}
});
imgexit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
overridePendingTransition(0, R.anim.end_in);
}
});
// load your setting that are you premium or not?
preferences = getSharedPreferences(PACKAGENAME,Context.MODE_PRIV ATE);
PACKAGENAME = getClass().getName();
Log.e("TAG", PACKAGENAME);
mIsPremium = preferences.getBoolean(KEY, false);
if (mIsPremium == true) {
updateUi();
return;
}
// show loading dialog with ProgressDialog
dialog = new ProgressDialog(this);
dialog.setMessage("loading...");
dialog.setCancelable(false);
dialog.setInverseBackgroundForced(false);
dialog.show();
String base64EncodedPublicKey = "MIHNMA0GCSqGSIbxxxEBAQUAA4G7ADCBtwKBrwDGhl8/QU3vPjgmTutAbItCBpdwwgFWSAFvzM/OOXVSMHaeH9fjRIxa3aLXVAfuoRJ3Q1ynbQL1Dc2hAvlTAgEeR FNmVkkjypzhZxK3O18wIYJiNleLd/pwwwwaoHeQB6s3eH3KB8uDn2TdZoYzmXxZkvMoDW2db3mT1NmP xJYm+xF7AN/p/Sr9YqEXpIpzsXbe6T30seUHmPDdM4r7h/r6hx/R/2hHvR/vnN0i6w8CAwEAAQ==";
// You can find it in your Bazaar console, in the Dealers section.
// It is recommended to add more security than just pasting it in your source code;
mHelper = new IabHelper(this, base64EncodedPublicKey);
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
// Hooray, IAB is fully set up!
mHelper.queryInventoryAsync(mGotInventoryListener) ;
}
});
}
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
if (result.isFailure()) {
Log.d(TAG, "Failed to query inventory: " + result);
dialog.hide();
return;
}
else {
Log.d(TAG, "Query inventory was successful.");
// does the user have the premium upgrade?
mIsPremium = inventory.hasPurchase(SKU_PREMIUM);
// update UI accordingly
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
}
dialog.hide();
updateUi();
setWaitScreen(false);
Toast.makeText(getApplicationContext(), mIsPremium? R.string.premium : R.string.notpremium, Toast.LENGTH_SHORT).show();
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};
public void onSavedUpgradeAppButtonClicked(View arg0) {
Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
setWaitScreen(true);
/* TODO: for security, generate your payload here for verification. See the comments on
* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
String payload = "gdhassdflsldaslfkahsjahsjakaasa";
mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, payload);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
} else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();
return true;
}
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
setWaitScreen(false);
return;
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
setWaitScreen(false);
return;
}
Log.d(TAG, "Purchase successful.");
if (purchase.getSku().equals(SKU_PREMIUM)) {
Log.d(TAG, "Purchase is premium upgrade. Congratulating user.");
alert("Thank you for upgrading to premium!");
mIsPremium = true;
updateUi();
setWaitScreen(false);
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "Destroying helper.");
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
// Update button with updateUi
public void updateUi() {
if (mIsPremium) {
imgq2=(Button)findViewById(R.id.imgq2);
imgq3=(Button)findViewById(R.id.imgq3);
imgq4=(Button)findViewById(R.id.imgq4);
imgqabout=(Button)findViewById(R.id.imgqabout);
imgq2.setEnabled(true);
imgq3.setEnabled(true);
imgq4.setEnabled(true);
imgqabout.setEnabled(false);
findViewById(R.id.imgq2).setBackgroundResource(R.d rawable.b);
findViewById(R.id.imgq3).setBackgroundResource(R.d rawable.c);
findViewById(R.id.imgq4).setBackgroundResource(R.d rawable.d);
findViewById(R.id.imgqabout).setBackgroundResource (R.drawable.u);
// change the mIsPremium to true
SharedPreferences.Editor newtask = preferences.edit();
newtask.putBoolean(KEY, true);
newtask.commit();
}
}
// Enables or disables the "please wait" screen.
void setWaitScreen(boolean set) {
findViewById(R.id.screen_wait).setVisibility(set ? View.VISIBLE : View.GONE);
}
void complain(String message) {
Log.e(TAG, "**** testbilling Error: " + message);
alert("Error: " + message);
}
void alert(String message) {
AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setMessage(message);
bld.setNeutralButton("OK", null);
Log.d(TAG, "Showing alert dialog: " + message);
bld.create().show();
}
}
Mainfest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.saeed.t"
android:versionCode="8"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR"></uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.saeed.t.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=".Q1"
android:screenOrientation="portrait"
android:noHistory="true"
>
</activity>
<activity
android:name=".Q2"
android:screenOrientation="portrait"
android:noHistory="true"
>
</activity>
<activity
android:name=".Q3"
android:screenOrientation="portrait"
android:noHistory="true"
>
</activity>
<activity
android:name=".Q4"
android:screenOrientation="portrait"
android:noHistory="true">
</activity>
</application>
</manifest>