本文整理汇总了Java中de.umass.lastfm.Authenticator类的典型用法代码示例。如果您正苦于以下问题:Java Authenticator类的具体用法?Java Authenticator怎么用?Java Authenticator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Authenticator类属于de.umass.lastfm包,在下文中一共展示了Authenticator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startLastFmSession
import de.umass.lastfm.Authenticator; //导入依赖的package包/类
public boolean startLastFmSession(String lastFmUsername, String lastFmPassword) {
// Last fm API set up
Caller lastFmCaller = Caller.getInstance();
lastFmCaller.setUserAgent(System.getProperties().getProperty("http.agent"));
lastFmCaller.setDebugMode(true);
lastFmCaller.setCache(new MemoryCache());
try {
mLastFmSession = Authenticator.getMobileSession(lastFmUsername, lastFmPassword, API_KEY, API_SECRET);
} catch (Exception e) {
Log.e(TAG, "Error while getting last.fm session", e);
return false;
}
return mLastFmSession != null;
}
开发者ID:sregg,项目名称:spotify-tv,代码行数:17,代码来源:LastFmApi.java
示例2: requestAuthorize
import de.umass.lastfm.Authenticator; //导入依赖的package包/类
public void requestAuthorize(String user, String pwd, Context c) throws ServiceCommException{
try{
session = Authenticator.getMobileSession(user, pwd, key, secret);
}catch(RuntimeException e){
throw new ServiceCommException(ServiceID.LASTFM, ServiceErr.IO);
}
if(session == null)
throw new ServiceCommException(ServiceID.LASTFM, ServiceErr.NOT_AUTH);
Editor editor = PreferenceManager.getDefaultSharedPreferences(c).edit();
editor.putString(PREF_SESSIONKEY, session.getKey());
editor.putString(PREF_USERNAME, session.getUsername());
editor.commit();
}
开发者ID:helderm,项目名称:songseeker,代码行数:17,代码来源:LastfmComm.java
示例3: getSession
import de.umass.lastfm.Authenticator; //导入依赖的package包/类
public void getSession(final String username, final String password, final LastfmWaiter loginWaiter) {
AsyncTask t = new AsyncTask() {
@Override
protected Object doInBackground(Object[] objects) {
try {
mSession = Authenticator.getMobileSession(username, password, API_KEY, API_SECRET);
if (mSession != null) {
mAccessKey = mSession.getKey();
mUserName = mSession.getUsername();
saveSession();
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
@Override
protected void onPostExecute(Object o) {
loginWaiter.onResult((Boolean)o);
}
};
t.execute();
}
开发者ID:jvanhie,项目名称:discogsscrobbler,代码行数:26,代码来源:Lastfm.java
示例4: getSession
import de.umass.lastfm.Authenticator; //导入依赖的package包/类
/**
* @see Authenticator#getSession(String, String, String)
*/
public Session getSession(String token, String apiKey, String secret) {
return Authenticator.getSession(token, apiKey, secret);
}
开发者ID:peterjosling,项目名称:scroball,代码行数:7,代码来源:LastfmApi.java
示例5: updateScrobbling
import de.umass.lastfm.Authenticator; //导入依赖的package包/类
private void updateScrobbling() {
if(musicPlayer.isActive() == false) {
return;
}
if(!preference.getBoolean(getString(R.string.pref_lastfm_scrobbling), false))
return;
checkState(musicPlayer.getCurrentTrack() != null);
Thread t = new Thread(new Runnable(){
Track track = musicPlayer.getCurrentTrack();
public void run() {
Session session = null;
try {
session = Authenticator.getMobileSession(
preference.getString(getString(R.string.pref_lastfm_username), ""),
preference.getString(getString(R.string.pref_lastfm_pwd), ""),
lastFM_key, lastFM_secret);
} catch (de.umass.lastfm.CallException ex) {
LOGGER.warn("de.umass.lastfm.CallException: {}", ex.getMessage());
}
if(session == null)
{
// LOGGER.debug("Could not log in");
Looper.prepare();
Toast.makeText(getBaseContext(),SonarflowApplication.getAppContext().getString(R.string.could_not_log_in), Toast.LENGTH_SHORT).show();
Looper.loop();
return;
}
try {
Thread.sleep(30000);
} catch (InterruptedException e1) {
LOGGER.debug("Could not sleep");
}
if(track == musicPlayer.getCurrentTrack() && musicPlayer.isPlaying())
{
int now = (int)(System.currentTimeMillis()/1000);
try{
ScrobbleResult result = de.umass.lastfm.Track.scrobble(
track.getArtistName(), track.getName(), now, session);
if(result.isSuccessful() && !result.isIgnored())
{
Looper.prepare();
Toast.makeText(getBaseContext(),SonarflowApplication.getAppContext().getString(R.string.current_song_scrobbled) , Toast.LENGTH_SHORT).show();
Looper.loop();
}}
catch(Exception e){
Looper.prepare();
LOGGER.error(e.getMessage());
Toast.makeText(getBaseContext(), SonarflowApplication.getAppContext().getString(R.string.problem_with_scrobbling) , Toast.LENGTH_SHORT).show();
Looper.loop();
}
}
}
});
t.start();
}
开发者ID:spectralmind,项目名称:sonarflow-android,代码行数:61,代码来源:PlayerService.java
示例6: getSession
import de.umass.lastfm.Authenticator; //导入依赖的package包/类
public Session getSession(String username, String password) {
return Authenticator.getMobileSession(username, password, Auth.KEY, Auth.SECRET);
}
开发者ID:josdem,项目名称:jmetadata,代码行数:4,代码来源:AuthenticatorHelper.java
注:本文中的de.umass.lastfm.Authenticator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论